Computers and Technology, 15.04.2020 23:53 Queiao4088
Modify the code to allow the user to enter any number of positive integers and calculate the average. In other words, the user could enter any 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). 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.
How can I make the code bellow allow any number of integers for the input?
// C code
// This program will calculate the sum of 10 positive integers.
// Developer: Faculty CMIS102
// Date: Jan 31,
#include
int main ()
{
/* variable definition: */
int count, value, sum;
double avg;
/* Initialize */
count = 0;
sum = 0;
avg = 0.0;
// Loop through to input values
while (count < 10)
{
printf("Enter a positive Integer\n");
scanf("%d", &value);
if (value >= 0) {
sum = sum + value;
count = count + 1;
}
else {
printf("Value must be positive\n");
}
}
// Calculate avg. Need to type cast since two integers will yield an integer
avg = (double) sum/count;
printf("average is %lf\n " , avg );
return 0;
}
Answers: 3
Computers and Technology, 23.06.2019 12:40
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c.transactions o d. rent tab
Answers: 1
Computers and Technology, 24.06.2019 10:00
Which two technologies support the building of single-page applications?
Answers: 2
Computers and Technology, 24.06.2019 12:30
Select all that apply. what two keys listed below should you use to enter data in an excel worksheet? tab backspace enter right arrow
Answers: 2
Computers and Technology, 25.06.2019 05:30
In 3-5 sentences describe how technology business professionals to be more efficient. include examples of hardware and software
Answers: 1
Modify the code to allow the user to enter any number of positive integers and calculate the average...
History, 18.08.2019 18:30
History, 18.08.2019 18:30
Social Studies, 18.08.2019 18:30
English, 18.08.2019 18:30
Mathematics, 18.08.2019 18:30
Chemistry, 18.08.2019 18:30
History, 18.08.2019 18:30
Mathematics, 18.08.2019 18:30