Sunday, January 20, 2013

CZ 1007 Lab 2 Q1
#include stdio.h
int main()
{
float sum =0, item, count =0, average;
int num;
printf("Enter number of lines:\n ");
scanf("%d",&num);
for(int i =1; i<=num; i++)
{
printf("Enter line %d : \n", i);
scanf("%f", &item);
while(item != -1)
{
sum +=item;
scanf("%f", &item);
count ++;
}
average = sum/count;
printf("Average = %f \n", average);
}
return 0;
}

No comments:

Post a Comment