PROGRAM TO CHECK WHETHER A GIVEN NUMBER IS PRIME OR NOT

/*PROGRAM TO CHECK WHETHER A GIVEN NUMBER IS PRIME OR NOT*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,b=0;
clrscr();
printf(“Enter any number: “);
scanf(“%d”,&n);
if(n<=1)
printf(“Given number is not a prime number”);
else
{
for(i=2;i<n;i++)
{
if(n%i==0)
b=1;
}
if(b==0)
printf(“Given number is a prime number”);
else
printf(“Given number is not a prime number”);
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *