#include<stdio.h>
main()
{
int num,i=2,f=0;
printf("\nEnter a number=");
scanf("%d",&num);
if(num==1)
printf("\n%d is neither prime nor composite",num);
else
{
while(i<=num/2)
{
if(num%i==0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("\n%d is a prime number",num);
else
printf("\n%d is a composite number",num);
}
}
main()
{
int num,i=2,f=0;
printf("\nEnter a number=");
scanf("%d",&num);
if(num==1)
printf("\n%d is neither prime nor composite",num);
else
{
while(i<=num/2)
{
if(num%i==0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("\n%d is a prime number",num);
else
printf("\n%d is a composite number",num);
}
}
No comments:
Post a Comment