Follow by Email

Friday, June 10, 2011

PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C

#include <math.h>
#include <stdio.h>
main()
{
  int i, j;
  i = 1;
  while ( i < 300 )
  {
            j = 2;
            while ( j < sqrt(i) )
            {
                        if ( i % j == 0 )
                                    break;
                        else
                        {
                                    ++j;
                                    continue;
                        }
            }
   if ( j > sqrt(i) )
            printf("%d\t", i);
    ++i;
  }
  return 0;
}

No comments:

Post a Comment