prime numbers between 1 to n
#include<stdio.h>
int main()
{
int num,i,count,n;
printf("Enter max range: ");
scanf("%d",&n);
for(num = 1;num<=n;num++)
{
count = 0;
for(i=2;i<=num/2;i++)
{
if(num%i==0){
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d
",num);
}
return 0;
}
#include
ReplyDeletemain()
{
int a, b, c,n;
printf("Enter the range:\n");
scanf("%d",&n);
printf("The prime numbers are:");
for(a=1;a<=n;a++)
{
c=1;
for(b=2;b<=a/2;b++)
{
if(a%b==0)
{
c=0;
break;
}
}
if(c==1)
{
printf("%d,", a);
}
}
getch();
}