hello every body
i have a problem with a c program .
the question that ( write a c program that reads a real numbers untill error then calculate the sum and the average of all numbers )
i have solve it with a while looping . and i need it with adiffrent looping .
#include<stdio.h>
void main()
{
float total,average;
int s;
float a;
while((scanf("%f",&a)>0))
{
total=total+a;
s=s+1;
}
average =total/s;
printf("The sum of numbers are %f and the average is %f",total,average);
}