Monday, March 26, 2012

Program to print all prime numbers upto n


/*****************<soeasyprograms.blogspot.in>******************/
/*Program to print all prime numbers upto n*/

#include<stdio.h>
#include<conio.h>
void main()
{
      int n,i,j;
      clrscr();
      printf("Enter the value of n\n\n");
      scanf("%d",&n);
      for(i=2;i<=n;i++)
      {
                for(j=2;j<i;j++)
                {
                 if(i%j==0)
                 break;
                 }
                if(i==j)
                 {
                  printf("\n   %d  ",i);
                 }
         }
     getch();
}
       /*End of program*/
/*****************<soeasyprograms.blogspot.in>******************/


No comments:

Post a Comment