Tutorial 5_Q2

Find the total and average of a sequence of 10 numbers stored in array. 


#include<stdio.h>
int main ()
{
double numbers[10],total,avg = 0;
int i;
for(i = 0;i < 10;i++)
{
  printf("enter the number %i:\n",i);
  scanf("%d",&numbers[i]);
  total += numbers[i];
}
avg = total/10;
printf("Total of sequence : %.2f\n",total);
printf("Average of sequence : %.3f",avg);
return 0;
}

0 comments:

Post a Comment