Friday, 15 September 2017

C program to find average of list of numbers entered through keyboard

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0,e;
float avg;
clrscr(); //to clear the screen

  printf(“How many elements:”);
scanf(“%d”,&n);
printf(“Enter all the elements one by one:”);
for(i=0;i<n;++i)
{
scanf(“%d”,&e);
sum+=e;
}
avg=sum/n;
printf(“nAverage=%f”,avg);
getch(); //to stop the screen
}

0 comments:

Post a Comment

Tech UOG