#include< stdio.h >
#include< conio.h >
void main()
{
int i=2,num;
clrscr();
printf("Enter a number:");
scanf("%d",&num);
while(num%i!=0)
{
i++;
}
if(num==i)
{
printf("The number %d is a prime Number",num);
}
else
{
printf("The number %d is not a prime number",num);
}
getch();
}
OUTPUT :
Enter a number :13
The number 13 is a prime Number
OR
OUTPUT :
Enter a number :12
The number 12 is not a prime Number
#include< conio.h >
void main()
{
int i=2,num;
clrscr();
printf("Enter a number:");
scanf("%d",&num);
while(num%i!=0)
{
i++;
}
if(num==i)
{
printf("The number %d is a prime Number",num);
}
else
{
printf("The number %d is not a prime number",num);
}
getch();
}
OUTPUT :
Enter a number :13
The number 13 is a prime Number
OR
OUTPUT :
Enter a number :12
The number 12 is not a prime Number
No comments :
Post a Comment