Write a program to find whether the entered number is a prime number or not

//this is a program to find whether the entered number is a prime number or not
#include<stdio.h>
#include<conio.h>
int main()
{
int i=2,flag=0,num;

printf("\n\nEnter The Number: ");
scanf("%d",&num);

while(num>i)
{
if(num%i==0)
{
flag=1;
break;
}
i++;
}
if(flag==0)
{
printf("\n\nThe Entered Number %d is a prime number",num);
}
else
{
printf("\n\nThe Entered Number %d is a not a prime number",num);
}
getch();
}

Previous
Next Post »