Check Prime Number or Not
#include<stdio.h>
#include<conio.h>
main()
{
int pm,i,flag=1;
printf("enter the number\n");
scanf("%d",&pm);
for(i=2;i<pm;i++)
{
if((pm % i)==0)
{
printf("Then given number is not prime\n");
flag=0;
break;
}
}
if (flag==1)
printf("The given number is prime\n");
}
#include
ReplyDeletemain()
{
int i,n,j;
printf("\tIT'S A PROGRAM TO CHECK A NUMBER PRIME OR NOT");
printf("\n\nEnter the number which you want to check:");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
printf("\n The given number is not prime\n");
break;
}
else
{
printf("\nThe given number is prime\n");
break;
}
}
}