Sunday, February 15, 2015

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

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

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clear the screen
int i,n,x,sum=0;

cout<<"How many numbers?";
cin>>n;

for(i=1;i<=n;++i)
{
cout<<"
Enter number "<<i<<": ";

cin>>x;
sum+=x;
}

x=sum/n;
cout<<"

Average="<<x;

getch(); //to stop the screen
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.