I am trying to write the code so it only enters a specific amount of numbers to average using a sentinel value.
[code]#include <stdio.h>
int main ()
{
/* variable definition: */
int count, value, sum; avg;
/* Initialize */
count = 0;
sum = 0; avg = 0.0;
// Loop through to input values
while(1){
printf("Enter the number of integers you want to add and find average of: ");
scanf("%d", &value);
if (value == 10)
break;
sum = sum + value;
count = count + 1; } else {
printf("Value must be positive\n"); }
}
// Calculate avg. of two integers
avg = sum/count;
printf("average is %ld\n ", avg );
return 0;
}