Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program using C language Compile and run the program averager.c. It is s

ID: 649960 • Letter: W

Question

Write a program using C language

Compile and run the program averager.c. It is supposed to repeatedly read a number, then reads that number of values and prints their average. When you run it, you should see input and output like this:

Determine what the program does if it encounters garbage in the input or end of file when it is trying to read an input value. There are two cases to worry about. What does it do if instead of the 5 above, you enter "garbage"? And what does it do if instead of the "10 20 ... 50", you enter "10 20 garbage"? Fix the program so that if it receives garbage input instead of integers for the expected number of values, it prints the following error message and quits.

Fix the program so that it prints the following error message and quits if it receives garbage input instead of integers when it is trying to read one of the values it should be averaging.

Explanation / Answer

int main() { int expected; int count; double sum; int value; while (scanf("%d", &expected) != EOF) { sum = 0; for (count = 0; count
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote