#include<stdio.h>
int isprime(int n)
{
int i,j;
for(i=2;i<=n/2;i++)
{
if(n%i==0)
return 0;
}
return 1;
}
main()
{
int num,i;
printf("\nEnter a number=");
scanf("%d",&num);
printf("\nPrime numbers less than %d are=",num);
for(i=2;i<=num;i++)
{
if(isprime(i)==1)
{
printf("%d ",i);
}
}
}
int isprime(int n)
{
int i,j;
for(i=2;i<=n/2;i++)
{
if(n%i==0)
return 0;
}
return 1;
}
main()
{
int num,i;
printf("\nEnter a number=");
scanf("%d",&num);
printf("\nPrime numbers less than %d are=",num);
for(i=2;i<=num;i++)
{
if(isprime(i)==1)
{
printf("%d ",i);
}
}
}
No comments:
Post a Comment