C++ program to find the prime numbers up to a range inputted by the user.
/* 4. write a program to find the prime numbers upto a range inputed by the
user*/
#include<iostream.h>
#include<conio.h>
void prime(int);
void main()
{
clrscr();
int no,r;
cout<<“Enter the range for printing prime:”<<endl;
cin>>r;
for(no=1;no<=r;no++)
prime(no);
getch();
}
void prime(int no)
{
int flag=0,i,r;
for(i=2;i<=no/2;i++)
{
if(no%i==0)
{
flag=1;
break;
}
}
if(flag==0)
{
cout<<“\t”<<no;
}
}