Question

Can you solve this C program by using Function? Q1. Write a C program to ring...

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.

Homework Answers

Answer #1

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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program which can be used to solve any system of equation using the Scaled...
Write a program which can be used to solve any system of equation using the Scaled Pivoting GE method
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int...
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int main() {    …. } Rewrite the program include the following statements. Include the header file fstream, string, and iomanip in this program. Declare inFile to be an ifstream variable and outFile to be an ofstream variable. The program will read data from the file inData.txt and write output to the file outData.txt. Include statements to open both of these files, associate inFile with...
You are to write a C program that will read from a file, one or more...
You are to write a C program that will read from a file, one or more sets of x,y coordinates. Each set of coordinates is part of a Cartesian system. A Cartesian coordinate system is a system that specifies each point uniquely in a plane by a pair of numerical coordinates. Your program will determine which quadrant each set belong. - Quadrants are often numbered 1st - 4th and denoted by Roman numerals: I(+,+), II (−,+), III (−,−), and IV...
Assignment 3 Write a C/C++ windows system program to move a file to a new location...
Assignment 3 Write a C/C++ windows system program to move a file to a new location using the MoveFile function. Write a C/C++ windows system program to delete a file using the DeleteFile function. Upload a ZIP folder containing your source codes.
Q) Write a computer program to test the stability of any continuous-time LTI system.( using Matlab)...
Q) Write a computer program to test the stability of any continuous-time LTI system.( using Matlab) Test your program on the impulse response.   h(t)= e^(-2t) u(t) Attached the program (Matlab) file and a screen shot of the results.
Write a program that solves exercises 1.3 or 1.5. If you solve both correctly, 20 extra...
Write a program that solves exercises 1.3 or 1.5. If you solve both correctly, 20 extra points will be given. For Exercise 1.3, you can use only the following C++ function or its Java equivalent to output the results of your program: void printDigit(char c ){     if (c=='-' || c=='+' || c=='.' || c == '\n' || (c>='0' && c<='9')){         cout << c;         return;     }          cout << "Invalid characters." << endl;     return;     ...
C programming 1. Create a file function.c that contains a function called printNumbers() that prints the...
C programming 1. Create a file function.c that contains a function called printNumbers() that prints the numbers 1 to 15. 2. Create a file function.h that contains the prototype for the printNumbers() function. 3. Create a file main.c that contains a main function that calls the printNumbers() function. You will need to be sure to include the header file. 4. Use gcc to compile the entire program (all files) without warnings. 5. Run the program and make sure that it...
Write a function to accept a header of a sorted linked and a name which can...
Write a function to accept a header of a sorted linked and a name which can be used as a key. If the key is found then add the record to the linked list using pointer(s). Do not write complete program. Write just one function. I just need a function that can demonstrate the prompt above.
Im using visual studio to write a c++ program has a function that will output the...
Im using visual studio to write a c++ program has a function that will output the number if ways a person can climb stairs using only 1 or two steps and and function that when given a number outputs the corresponding fibonacci number. I want to call the functions in main;
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...