Write a program to print average of two numbers enter by the user.
Answers
Answered by
0
Answer:
#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;
}
Explanation:
for ex
A user entered input as
4 and 8.
the code will count their sum and divide the sum by 2
hence output will be (4+8)/2 = 6
Similar questions