forked from Yash-Raj-Singh/2nd_sem_oops_files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprime.cpp
38 lines (35 loc) · 781 Bytes
/
prime.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
#include <iostream>
using namespace std;
void prime(int a, int b)
{
int i, c;
while (a < b)
{
c = 0;
for(i = 2; i <= a/2; ++i)
{
if(a % i == 0)
{
c = 1;
break;
}
}
if (c == 0)
cout << a << " ";
++a;
}
}
int main()
{
int a, b;
cout << "Enter the lower interval : ";
cin >> a;
cout<<endl;
cout<<"Enter the higher interval : ";
cin >> b;
cout<<endl;
cout << "Prime numbers between " << a << " and " << b<< " are: ";
prime(a,b);
cout<<endl;
return 0;
}