Program :
#include<stdio.h>
void main()
{
int num,a=2;
printf("Enter any number");
scanf("%d",&num);
while(a<num)
{
if(num%a==0)
{
printf("%d is a non Prime number", num);
break;
}
a++;
}
if(a==num)
{
printf("%d is a Prime number",num);
}
else if( num==0 || num==1)
{
printf("%d is neither Prime nor composite number",num);
}
}
#include<stdio.h>
void main()
{
int num,a=2;
printf("Enter any number");
scanf("%d",&num);
while(a<num)
{
if(num%a==0)
{
printf("%d is a non Prime number", num);
break;
}
a++;
}
if(a==num)
{
printf("%d is a Prime number",num);
}
else if( num==0 || num==1)
{
printf("%d is neither Prime nor composite number",num);
}
}
No comments:
Post a Comment