Write a complete C++ program that reads two whole numbers into two variables of type int, and then outputs both the whole number part and the remainder when the first number is divided by the second. This can be done using the operators / and %.
Program Code:
#include <iostream>
using namespace std;
int main ()
{
//Reads two whole numbers into two variables
//of data type int
int firstNumber, secondNumber;
cout << "Enter two interger numbers: ";
cin >>firstNumber >> secondNumber;
//Display outputs both the whole number part and the
//remainder when the first number is divided by the second.
cout << firstNumber << " is divided by " << secondNumber
<< " are equals to " << (firstNumber/secondNumber)
<< " and a remainder is " << (firstNumber%secondNumber)
<< endl;
return 0;
}
Output of the program code:
Enter two interger numbers: 100 9
100 is divided by 9 are equals to 11 and a remainder is 1