Sunday 28 December 2014

Program to Check if a number is Prime or not

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=2,count=0;
printf("Enter the No.\n");
scanf("%d",&n);
while(i<=n/2)
{
if(n%i==0)
count++;
i++;
}
if(count==0)
printf("The No. is Prime");
else
printf("The No. is Not Prime");
getch();
}