C++ program to find the average of a list of numbers entered through the 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<<“nEnter number “<<i<<“: “;
cin>>x;
sum+=x;
}

x=sum/n;
cout<<“nnAverage=”<<x;
getch(); //to stop the screen
}

Output

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

Leave a Comment

error: Alert: Content is protected!!