hi friends, im a newbie at C,
im trying to code for a program which cud return all prime numbers in a specific range.
its returning the results with an error, which is , it also includes the products of two prime numbers in results,
for example 15=3*5 and 21=3*7
my code is
---------------------------------------------------------
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
for (int i=1;i<=300;i++)
{
for(int j=2;j<=i;j++)
if(i%j==0 )
break;
else
{
printf("\t%d ",i);
break;
}
}
getche();
}
--------------------------------------------------
Result:
3 5 7 9 11 13 15 17 19 21 23 .................
kindly guide me where the problem resides.
which is letting 15,21 etc in output.