Program to find the number prime or not

Program to find the number prime or not
//Program to find the number prime or not
#include <iostream.h>
#include <conio.h>
int PRIME(int N);
void main()
{clrscr();
 int i,n;
 cout<<"\n Enter Any no :";
 cin>>n;
 int x=PRIME(n);
 if(x==0)
 cout<<"\n Not a Prime :";
 else
 cout<<"\n Yes It is Prime :";
getch();
}
int PRIME(int N)
{int I,FLAG=0;
 for(I=2;I<N;I++)
 {FLAG=N%I;
 if( FLAG==0)
 return 0;
 }
 return 1;
}
Program to find the number prime or not Program to find the number prime or not Reviewed by SHERE KHOJRAHA on February 16, 2019 Rating: 5

No comments:

Powered by Blogger.