This program is having probl;ems accepting inputs and was wondering
This program is having probl;ems accepting inputs and was wondering
what is wrong with it. I do not have alot of time to figure this out as I go so its a program that take 3 spartan races and averages them together. I am using c code and ideone.com for a compiler.
// C code
// this program will calculate the average of 3 spartan race times.
// Developer: Jeremy Perkins
// Date: Aug 07, 2016
#include
float Average(int);
int main ()
{
/* variable definition: */
int value,sum,count,intsum;
float avg;
/* Initialize */
count = 3;
sum = 0;
value = 0;
// Loop through to input values
while (count {
printf(“Enter number of Spartan races run\n”);
scanf(“%d”, &value);
if (value >= 0)
{
sum = sum + value;
count = count – 1;
}
else {
printf(“Only enter positive integers\n”);
}
}
// Call Average Function
avg = Average(intsum);
printf(“Average of Spartan race times is %f\n”, avg);
return 0;
}
//Calculate avg.
float Average(int sum)
{
return sum/3.0;
}