#include <iostream>
using namespace std;
void prime_numbers(int start, int stop)
{
int f;
for (int i = start; i <= stop; i++) {
if (i == 1 || i == 0)
continue;
f = 1;
for (int j = 2; j <= i / 2; ++j) {
if (i % j == 0) {
f = 0;
break;
}
}
if (f == 1)
cout << i << " ";
}
}
int main()
{
int start;
int stop;
cout<<"\nEnter the start number: ";
cin>>start;
cout<<"\nEnter the stop number: ";
cin>>stop;
cout<<"\nThe prime numbers between "<<start<<" and "<<stop<<" are: ";
prime_numbers(start,stop);
return 0;
}
Comments
Leave a comment