Tuesday, 24 February 2015

Prime Number Program in C++

#include<stdio.h>
#include<conio.h>
main()
{
int prime,i,b=0;
clrscr();
printf("\n Enter Number To Check Whether Prime or Not\n");
scanf("%d",&prime);

for(i=2;i<prime;i++)
{
if(prime%i==0)
{
b=1;
break;
}
}
if(b==0)
{
printf("\n Given Number is Prime");
}
else
{
printf("\n Given Number is Not Prime");
}
getch();
}

No comments:

Post a Comment