Reads in five integers and determines and prints the largest and the smallest integers. Use macro - C++ Data Type

C++ examples for Data Type:int

Description

Reads in five integers and determines and prints the largest and the smallest integers. Use macro

Demo Code

#include <iostream>

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

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

    std::cout << "Enter five integers: ";
    std::cin >> num1 >> num2 >> num3 >> num4 >> num5;

    std::cout << "Max: " << MAX(num1, MAX(num2, MAX(num3, MAX(num4, num5))))
              << std::endl;
    std::cout << "Min: " << MIN(num1, MIN(num2, MIN(num3, MIN(num4, num5))))
              << std::endl;

    return 0;
}

Result


Related Tutorials