Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Modify the code to allow the user to enter an unspecified number of positive integers

Modify the code to allow the user to enter an unspecified number of positive integers and

calculate the average. In other words, the user could enter number of positive integers. (Hint:

You can prompt the user for how many they want to enter. Or; you could use a sentinel value to

trigger when the user has completed entering values). You may need to conduct some research

on your own to solve this problem. Prepare a new test table with at least 3 distinct test cases

listing input and expected output for the code you created. Support your experimentation with

screen captures of executing the new code.

// C code
// This program will calculate the sum of 10 positive integers.
// Developer: Alicia Bush, Student UMUC CMIS 102
// Date: Date: April 11, 2016
#include
int main ()
{

int counter = 0, num_values;
int num, sum = 0;
float average;

printf(“How many numbers to find the average for? “);
scanf(“%d”, &num_values);

//loop 10 times
while (counter printf(“Enter a number: “);
scanf(“%d”, &num);
sum = sum + num;
counter = counter + 1;
}

average = (float)sum/(float)num_values;

printf(“The average is %.2f\n”,average);
}

(stdin: 20 40 60 80)

It keeps giving me this average: 77.00 (THIS IS NOT RIGHT) Tha answer should be 50. I do not know what I am doing wrong.

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"