This C++ Program which checks if a number is divisible by second number. The program takes two numbers as the input and uses modulus operator to determine whether the first number is completely divisible by second number.

Here is source code of the C++ program which checks if a number is divisible by second number. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C++ Program to Check if a Number is Divisible By Second Number`

`*/`

`#include<iostream>`

`using namespace std;`

int main()

`{`

int first, second;

cout << "Enter the numbers : ";

cin >> first >> second;

if (first % second == 0)

cout << "First number " << first

<< " is divisible by second number "

<< second;

`else`

cout << "First number " << first

<< " is not divisible by second number "

<< second;

`}`

$ g++ main.cpp $ ./a.out Enter the numbers : 34 17 First number 34 is divisible by second number 17 $ ./a.out Enter the numbers : 104 12 First number 104 is not divisible by second number 12

**Sanfoundry Global Education & Learning Series – 1000 C++ Programs.**

If you wish to look at all C++ Programming examples, go to C++ Programs.