Program to find the number prime or not

Tuesday, August 11, 2020

//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;

}

You Might Also Like

0 Comments

Like us on Facebook

Flickr Images

Flickr Short Films