Answer to Question #185299 in C++ for Uxair

Question #185299

 Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number followed by the words "is larger." If the numbers are equal, print the message "These numbers are equal."


1
Expert's answer
2021-04-25T11:31:50-0400
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    if (a == b) {
        std::cout << "These numbers are equal.\n";
    }
    else {
        std::cout << (a > b? a: b) << " is larger.\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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS