Menu
 

program to find all prime numbers in a certain range  through c

#include<stdio.h>
int main()
{
  int n,i=1,j,c;
  printf("Enter the limit:");
  scanf("%d",&n);
  printf("The prime numbers are :");
  while(i<=n)
  {
     c=1;
     for(j=2;j<=i/2;j++)
     {
       if(i%j==0)
       c=0;
     }
  if(c==1)
     printf("%d,",i);
     i++;
   }
  printf("\b \b");
  return(0);
}

Post a Comment

 
Top