Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include int main ( int argc, char ** argv) { int i; int count; int total; int val; double average; /* prompt the user for

#include

int main (int argc, char** argv)

{

int i;

int count;

int total;

int val;

double average;

/* prompt the user for input */

printf ("Enter in a list of numbers followed by the terminal value of -999 ");

/* loop until the user enters -999 */

scanf ("%d", &val);

while (val != -999)

{

total = total + val;

count++;

scanf("%d", &val);

}

/* calculate the average of the values read in */

average = total / count;

/* display the results */

printf ("For the list of %d numbers with a total of %d ", count, total);

printf (" the average is: %15.5f ", average);

return 0;

}

image text in transcribedimage text in transcribed

Access the program lablb.c from the Lab Exercises page. This program is to read in a list of integers until the value of-999 is input. It then is to print out the number of value read, the total of these values and the average of these values. However, this program does contain some errors. 6. Fill in the table below with the expected values for the variables count, total and average if the program is run with input of 2 4 6 8 -999 Compile and run the program. Fill in the table below with the actual values produced by the program? Expected Value Actual Value Value of variable: count Value of variable: total Value of variable: average Does the program produce the expected output? If not, you may need to fix the error before moving to the next question. 7. Fill in the table below with the expected values for the variables count, total and average if the program is run with input of: 2 3 5 -999 Compile and run the program. Fill in the table below with the actual values produced by the program? Expected Value Actual Value Value of variable: count Value of variable: total Value of variable: average Does the program produce the expected output? If not, you may need to fix the error before moving to the next question. 8 program is run with input of: 8. Fill in the table below with the expected values for the variables count, total and average if the -999 Compile and run the program. Fill in the table below with the actual values produced by the program? Expected Value Actual Value Value of variable: count Value of variable: total Value of variable: average Does the program produce the expected output? 9 What errors contained in the program were exposed in the above test cases? 10. Give a definition that would define when we can call a program "error free

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions