(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;
}
Post A Comment:
0 comments: