Read two integers from user, prints the larger number followed by the words 'is larger', use macro - C++ Language Basics

C++ examples for Language Basics:Console

Description

Read two integers from user, prints the larger number followed by the words 'is larger', use macro

Demo Code

#include <iostream>

#define MAX(a, b) ((a > b) ? a : b)//from ww w .j a v  a2 s.c  o  m

int main(int argc, const char *argv[]) {
    int num1, num2;

    std::cout << "Enter two integers: ";
    std::cin >> num1 >> num2;

    if (num1 == num2)
        std::cout << "These numbers are equal" << std::endl;
    else
        std::cout << MAX(num1, num2) << " is Larger." << std::endl;
    return 0;
}

Result


Related Tutorials