This program currently uses all while loops. Copy it into a new file counters2.c, and rewrite the program so that it uses only for loops rather than while loops. Make this change one loop at a time, and make sure your change doesn't change the output the program produces.
It now uses a for loop to read its input. Rewrite it to use a while loop rather than a for.
5 10 20 30 40 50 Average of 5 values is 30.00 7 15 20 40 50 60 40 50 Average of 7 values is 39.29Determine 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.
5 10 20 30 40 50 Average of 5 values is 30.00 some garbage input Error! Can't read number of expected values.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.
5 10 20 30 40 50 Average of 5 values is 30.00 6 50 70 whatever 40 60 Error! Can't read expected value #2. Average of 2 values is 60.00
If you are in Section 001 use:
grade -lab10s1,ee160 *.c *.hIf you are in Section 002 use:
grade -lab10s2,ee160 *.c *.hIf you are in Section 003 use:
grade -lab10s3,ee160 *.c *.hIf you are in Section 004 use:
grade -lab10s4,ee160 *.c *.hIf you are in Section 005 use:
grade -lab10s5,ee160 *.c *.hNOTE: this command will send in ALL files named with .c and .h extensions in the current directory which are really your files. The grade command will give you a message for files that are links and not submit the files - that is ok, we only want the files which you wrote. You should verify that you turned in things successfully, which you can do with the command (which simply leaves the file names off from the previous command).
grade -lab10s1,ee160 OR grade -lab10s2,ee160 OR grade -lab10s3,ee160 OR grade -lab10s4,ee160 OR grade -lab10s5,ee160NOTE: after the files are prepared for grading, you will no longer be able to see your file listing using the above command. NOTE: BE CAREFUL to use the correct form of the grade command given above. If you do not, your files will be sent to the wrong place, and we will not guarantee we will find them for grading.