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("
Average=%f",avg); getch(); //to stop the screen}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.