-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday4.cpp
More file actions
42 lines (37 loc) · 679 Bytes
/
day4.cpp
File metadata and controls
42 lines (37 loc) · 679 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
42
//check if a no. is prime or not
# include <iostream>
using nmaespace std;
int main(){
int n;
cin>>n;
int i;
for(i=2;i<n;i++){
if(n%i==0){
cout<<"non-prime"<<endl;
break;
}
}
if(i==n){
cout<<"Prime"<<endl;
}
return 0;
}
//print all prime nos. between a and b
# include <iostream>
using namespace std
int main(){
int a,b;
cin>>a>>b;
for(num=a; num<=b; num++){
int i;
for(i=2; i<num; i++){
if(num%i==0){
break;
}
}
if(i==num){
cout<<num<<endl;
}
}
return 0;
}