In: Computer Science
Programming Language C++ Program to determine whether the first number is divisible by the second number, display the remainder of two number and display the integers in non-decreasing order.
#include <iostream>
using namespace std;
int main()
{
//variable declaration
int firstNumber, secondNumber, rem;
cout<<"Enter the first number: ";
cin>>firstNumber;
cout<<"Enter the second number: ";
cin>>secondNumber;
if(secondNumber != 0)
{
//calculate remainder
rem = firstNumber % secondNumber;
if(rem == 0)
cout<<"The first number is divisible by the second
number";
else
cout<<"The first number is not divisible by the second
number";
cout<<endl<<"The remainder is: "<<rem;
}
if(firstNumber<secondNumber)
cout<<endl<<"Decreasing order is:
"<<firstNumber<<" "<<secondNumber;
else
cout<<endl<<"Non-decreasing order is:
"<<secondNumber<<" "<<firstNumber;
return 0;
}
INPUT:
Enter the first number: 20
Enter the second number: 15
OUTPUT:
The first number is not divisible by the second number
The remainder is: 5
Non-decreasing order is: 15 20