Thursday 12 January 2012

C++ PROGRAM TO SUM AND AVERAGE

#include< iostream.h>
#include< conio.h>
void main() // can use int but last u have to return 0.
{
int a,b,c,d,sum,avg;
cout<<"Enter the four numbers:\n";
cin>>a>>b>>c>>d;
sum=a+b+c+d;
cout<<"The sum of the numbers is:"<< sum <<"\n";
avg=sum/4; /* devide it by the number of numbers you enter
for ex. you entered 7 number divide by 7*/
cout<<"The average of the numbers is:"<< avg;
// return 0; (if using int main)

}
/* if you copy this code please remove space in header files , sum and avg.