-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass44.cpp
More file actions
41 lines (36 loc) · 826 Bytes
/
class44.cpp
File metadata and controls
41 lines (36 loc) · 826 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
39
40
41
#include <iostream>
using namespace std;
int main(){
int a,b=1;
bool isprime,even;
cout<<"enter a number: ";
cin>>a;
for (int i=1; i<a; i++){
if (a%i==0){
isprime=true;
}
else{
isprime=false;
b++;
}
}
if (a%2==0){
even=true;
}
else {
even=false;
}
if (even==true && isprime==true){
cout<<"number is prime at"<<b<<"and number is even."<<endl;
}
else if(even == true && isprime==false){
cout<<"number is even and not prime"<<endl;
}
else if (even==false && isprime==true){
cout<<"number is odd and prime at : "<< b<<endl;
}
else {
cout<<"number is odd and not prime"<<endl;
}
return 0;
}