Jan 29, 2013

Prime Numbers (0-20)

/*Prime Numbers (0-20)*/

# include"stdio.h"
#include"conio.h"
void main()
{
//main starts
clrscr();
int i;
printf("Series of prime numbers up to 20 is=\n");
for(i=2;i<=20;i++)
{
for(j=2;j<=20;j++)
if(i%j==0)
break;
}
if(i==j)
printf("%3d",i);
}
getch();
}

Output................
...................................Series of prime numbers up to 20 is=......................................................
.......................................2 3 5 7 11 13 17 19 ......................................................................

No comments:

Post a Comment

Thank you for visit this site. You will get many programming news from here and learn programming very easily.

Popular Posts