Social Icons

Saturday, 15 February 2014

Program to find average of numbers

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

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

cout<<"\n How many numbers you want to enter : ";
cin>>n;

for(i=1;i<=n;++i)
{
cout<<"\n Enter number"<<i<<" : ";
cin>>x;
sum+=x;
}

x=sum/n;
cout<<"\n\n\t Average = "<<x;
getch();         //to stop the screen
}


                                                            Output

No comments:

Post a Comment