teaching myself C++ prob.
Hi, I hope I got this code tab thing right?
anyway, I want to make this programme, which i am following an exercise out of a book! If the first number is a multiple of the second. Sometimes it works sometimes it dont, what am I doing wrong? In easy terms please
Code:
#include <iostream>
using namespace std;
int num1;
int num2;
int answer;
int main()
{
cout << "Enter two numbers to find the multiple of each other" << endl;
cout << "Enter number 1" << endl;
cin >> num1;
cout << "Enter number 2" << endl;
cin >> num2;
answer = num1 % num2;
if( answer == 1 )
cout << num1 <<" and " << num2 << " are NOT multiples of each other" << endl;
if( answer == 0 )
cout << num1 <<" and " << num2 << " ARE multiples of each other" << endl;
return 0;
}
Thanks