Friday, 12 June 2015

C++ Program to enter two integers and find their Sum and Average

#include <iostream.h> 
#include <conio.h>
void main() 
clrscr(); 
int x,y,sum; 
float average; 
cout << "Enter 2 integers : " << endl; 
cin>>x>>y; 
sum=x+y; 
average=sum/2; 
cout << "The sum of " << x << " and " << y << " is " << sum 
     << "." << endl; 
cout << "The average of " << x <<  " and " << y << " is " << average 
     << "." << endl; 
getch(); 
}
 
Output:
 
The sum of 8 and 6 is 14
The average of 8 and 6 is 7

No comments:

Post a Comment