FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 101   



Following program shows you how to find largest number from given 2 numbers.
In this program we get inputs from user and shows largest number from given two numbers using if condition

#include <iostream>
int main() {
    int input1;
    int input2;

    std::cout << "Enter first number:";
    std::cin >> input1;

    std::cout << "Enter second number:";
    std::cin >> input2;

    if (input1 == input2) {
        std::cout << input1 << " is equal to " << input2;

    } else if (input1 > input2) {
        std::cout << input1 << " is larger than " << input2;

    } else {
        std::cout << input1 << " is lesser than " << input2;
    }
}

Output:

Example1:

Enter first number: 7
Enter second number: 7
7 is equal to 7

Example2:

Enter first number: 200
Enter second number: 50
200 is larger than 50

Example3:

Enter first number: 25
Enter second number: 85
25 is lesser than 85



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News