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
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...
write an AVR C program code to create 5 inputs with corresponding 5 different outputs. The...
write an AVR C program code to create 5 inputs with corresponding 5 different outputs. The instruction is listed to follow.  Specify your 5 inputs and 5 outputs. Describe your method .The Conditions: ? AVR C code must be used , Any conditional statement must be used (e.g. IF statement or CASE statement) at least one time, must use the time delay for your output and Bit-wise logic and shift operator.
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a...
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a program that receives two numbers from the user and uses your written library to calculate the reminder after division, the addition, and the subtraction of these two input numbers. (Hint your library should include three functions. Your header file should not contain the code for any of these functions, it should contain only the instructions for how to use the library).
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
(a) Write a function in C++ called readNumbers() to read data into an array from a...
(a) Write a function in C++ called readNumbers() to read data into an array from a file. Function should have the following parameters: (1) a reference to an ifstream object (2) the number of rows in the file (3) a pointer to an array of doubles The function returns the number of values read into the array. It stops reading if it encounters a negative number or if the number of rows is exceeded. (b) Write a program with the...
Code a C file, following these instructions: This lab is about getting the input from a...
Code a C file, following these instructions: This lab is about getting the input from a file. Let’s assume the words are provided in one file, passed as an argument to your program. The names of the files are provided as arguments to your program (i.e., they are copied by the shell in the argv variable), and each file is a text file with lots of words. Open the manual page for open() system call and add to your code...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT