-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ_2_21L_7567.cpp
More file actions
38 lines (29 loc) · 907 Bytes
/
Copy pathQ_2_21L_7567.cpp
File metadata and controls
38 lines (29 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream> //solution of Q2 of assignment 1
using namespace std;
int main(){
int num_1,num_2=0;
cout<<"Enter 2 numbers to check if they are multiples of each other \n";
cout<<"Enter first number: ";
cin>>num_1;
cout<<"Enter second number: ";
cin>>num_2;
//nested if statements are used so program can work properly even
//if user enters larger number after small number
if (num_1>num_2){
if (num_1%num_2==0){
cout<< num_1 <<" is multiple of "<<num_2<< "."<<endl;
}
else {
cout<<"NON";
}
}
else if (num_1<=num_2){
if (num_2%num_1==0){
cout<< num_2 <<" is multiple of "<<num_1<< "."<<endl;
}
else {
cout<<"NON";
}
}
return 0;
}