Find the average of two numbers given by the user.
#include <iostream>
using namespace std;
int main() {
int a, b, sum;
double avg;
cout << "Enter the first integer number: ";
cin >> a;
cout << "Enter the second integer number: ";
cin >> b;
sum = a + b;
avg = (double)sum / 2;
cout << "\nThe average of your numbers is: " << avg << "\n";
return 0;
}
Comments
Leave a comment