Print Friendly and PDF
(Multiples) Write a program that reads in two integers and determines and prints if the first is a multiple of the second. [Hint: Use the modulus operator.]
(Multiples) Write a program that reads in two integers and determines and prints if the first is a multiple of the second. [Hint: Use the modulus operator.]

Solution:


#include <iostream>
using std::cin;
using std::cout;
using std::endl;
 
int main()
{
  int x, y;
 
  cout << "Enter the two integers.\n";
  cin >> x >> y;
 
  if (x % y == 0)
    cout << "first is a multiple of the second.\n";
  else
    cout << "first is not a multiple of the second.\n";

   return 0;
}
 
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: