#include<conio.h>
#include<iostream.h>
void check_prime (int x,int y);
void main()
{ clrscr();
int x,y,z;
cout<<"Enter the range below" ;
cout<<"From ";
cin>>x;
cout<<"To ";
cin>>y;
check_prime(x,y);
getch();
}
void check_prime(int x,int y)
{ int a,b,c,d;
for(int i=x;i<=y;i++)
{ int ret=0;
for (int j=1;j<=i;j++)
{ c=i%j;
if (c==0)
{ ret++;
}
}
if (ret==2)
{ cout<<i<<" is a prime no. \n";
}
}
getch();
}
#include<iostream.h>
void check_prime (int x,int y);
void main()
{ clrscr();
int x,y,z;
cout<<"Enter the range below" ;
cout<<"From ";
cin>>x;
cout<<"To ";
cin>>y;
check_prime(x,y);
getch();
}
void check_prime(int x,int y)
{ int a,b,c,d;
for(int i=x;i<=y;i++)
{ int ret=0;
for (int j=1;j<=i;j++)
{ c=i%j;
if (c==0)
{ ret++;
}
}
if (ret==2)
{ cout<<i<<" is a prime no. \n";
}
}
getch();
}
No comments:
Post a Comment