C Program to check wheather a number is prime or not - With Output

#include<stdio.h>
#include<conio.h>

void main()
{
int num,i;
bool flag=true;
printf(“Enter any number”);
scanf(“%d”,&num);

for(i=2;i<=(num/2);++i)
{
                if(num%i==0)
{
          flag=false;
break;
}

}

if(flag==flase)
printf(“Number is not Prime”);
else
printf(“Number is Prime”);

getch();

}

OUTPUT :
Enter any number  5

Number is Prime
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment