#include<stdio.h>
int main()
{
int num,a,b;
printf("Enter number to check prime:");
scanf("%d",&num);
for(a=1;a<num;a++)
{
int count=0;
for(b=1;b<a;b++)
{
if(a%b==0)
{
count++;
}
}
if(count==0||count==1)
{
printf("%d is prime number\n",a);
}
else
{
printf("%d is not prime number\n",a);
}
}
getch();
return 0;
}
int main()
{
int num,a,b;
printf("Enter number to check prime:");
scanf("%d",&num);
for(a=1;a<num;a++)
{
int count=0;
for(b=1;b<a;b++)
{
if(a%b==0)
{
count++;
}
}
if(count==0||count==1)
{
printf("%d is prime number\n",a);
}
else
{
printf("%d is not prime number\n",a);
}
}
getch();
return 0;
}
Comments
Post a Comment