Monday, 19 October 2015

C program to check whether a no. is prime or not

#include<stdio.h>
#include<conio.h>
void main()
{
int x,i,y=0;
clrscr();
printf("\n enter any no.:");
scanf("%d",&x);
for(i=2;i<=x/2;i++)
{
if(x%i==0)
          y=1;
}
if(y==0)
          printf("\n %d is prime no.",x);
else
          printf("\n %d isn't prime no.",x);
getch();
}

No comments:

Post a Comment