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

Program

#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
}

Output

Leave a Comment

error: Alert: Content is protected!!