Reads in two integers and determines and prints if the first is a multiple of the second. - C++ Data Type

C++ examples for Data Type:int

Description

Reads in two integers and determines and prints if the first is a multiple of the second.

Demo Code

#include <iostream>

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

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

    std::cout << num1 << ((num1 % num2 == 0) ? " is " : " is not ")
              << "a multiple of " << num2 << std::endl;
    return 0;/*from w  ww . j  a v a 2 s . com*/
}

Result


Related Tutorials