Answer to Question #191836 in C++ for Rahel Aschalew

Question #191836

Find the average of two numbers given by the user.


1
Expert's answer
2021-05-11T07:05:46-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment