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 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...
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
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;     ...
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.
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...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
Use MARS to write and simulate a MIPS assembly language program to swap two of the...
Use MARS to write and simulate a MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. Download the template file “P4_template.asm” provided on Blackboard. Add your code to this file. Do not modify any of the code provided in the file. The main function should: • Pass the starting address of the array in $a0....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT