-
Notifications
You must be signed in to change notification settings - Fork 0
/
OddOrEven.cpp
133 lines (105 loc) · 2.36 KB
/
OddOrEven.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int num1, num2;
bool r=true ,s=true, t=true, t1=true;
int ne;
int ne1;
cout<<"Enter Num1: ";
cin>>num1;
cout<<"Enter Num2: ";
cin>>num2;
cout<<"\n";
if(num1>num2){
cout<<"Num1: "<<num1<<" is higher than Num2: "<<num2;
}else if(num1==num2){
cout<<"Num1: "<<num1<<" is equal to Num2: "<<num2;
}else{
cout<<"Num2: "<<num2<<" is higher than Num1: "<<num1;
}
cout<<"\n";
cout<<"\n";
if(num1>=0){
cout<<"Num1: "<<num1<<" is positive number \n";
}else{
cout<<"Num1: "<<num1<<" is negative number \n";
}
if(num2>=0){
cout<<"Num2: "<<num2<<" is positive number \n";
}else{
cout<<"Num2: "<<num2<<" is negative number \n";
}
cout<<"\n";
////////////////for num1
for(int k=0; k>=num1; k++){
if(num1=-num1){
t=false;
num1*-1;
}}
for(int i=2; i<=num1/2; i++){
if(num1%i!=0){
r=false;
}
}
/////////////for num2
for(int a=0; a>=num2; a++){
if(num2=-num2){
t1=false;
num2*-1;
}}
for(int i=2; i<=num2/2; i++){
if(num2%i!=0){
s=false;
}
}
////////////////for num1
if(r==true){
if(r!=t){
ne=num1*-1;
num1=ne;
cout<<"Num1: "<<ne<<" is Even number \n";
}else{
cout<<"Num1: "<<num1<<" is Even number \n";
}
}else if(r==t){
ne=num1*-1;
num1=ne;
cout<<"Num1: "<<ne<<" is Odd number \n";
}else{
cout<<"Num1: "<<num1<<" is Odd number \n";
ne=num1;
}
/////////////for num2
if(s==true){
if(s!=t1){
ne1=num2*-1;
num2=ne1;
cout<<"Num2: "<<ne1<<" is Even number \n";
}else{
cout<<"Num2: "<<num2<<" is Even number \n";
}
}else if(s==t1){
ne1=num2*-1;
num2=ne1;
cout<<"Num2: "<<ne1<<" is Odd number \n";
}else {
ne1=num2;
cout<<"Num2: "<<num2<<" is Odd number \n";
}
cout<<"\n";
///////////////for num1
if(num1%3==0){
cout<<"Num1: "<<num1<<" is divisible by 3 \n";
}else{
cout<<"Num1: "<<num1<<" is not divisible by 3 \n";
}
////////////for num2
if(num2%3==0){
cout<<"Num2: "<<num2<<" is divisible by 3 \n";
}else{
cout<<"Num2: "<<num2<<" is not divisible by 3 \n";
}
cout<<"\n";
system("pause");
}