Can you solve this C program by using Function?
Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
I have written code and attached code snippet here.Run this code in your machine and computer bell will ring with 1 second delay.
#include<stdio.h>
#include <time.h>
int main()
{
printf("Number of times to ring computer bell : ");
int num,i;
scanf("%d", &num);
for(i=0;i<num;i++)
{
printf("\a"); //ring computer bell
clock_t start_time = clock();
while (clock() < start_time + 1000); //Delay of 1 second.
}
return 0;
}
Screenshot:
Get Answers For Free
Most questions answered within 1 hours.