CHECK WHETHER GIVEN NUMBER IS PRIME OR NOT


#include<stdio.h>
#include<conio.h>
void main()
{
int num, i;
printf("Enter a number");
scanf("%d",&num);
if(num>2)
{
for(i=2; i < num; i++)
{
if(num % i == 0)
break;
}
if(i != num)
printf("Number is not prime");
else
          printf("Number is prime");
}
else
  printf("Number not prime");
}

0 comments: (+add yours?)

Post a Comment