This program takes in two integers x and y as a screen input from the user.
The sum and average of these two integers are calculated and outputted using the ‘cout’ command.
Example:The sum and average of these two integers are calculated and outputted using the ‘cout’ command.
#include<iostream>
using namespace std;
int main(){
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;
system("pause");
}
Enter 2 integers :
1215
The sum of 12 and 15 is 27.
The average of 12 and 15 is 13.
No comments:
Post a Comment