Thursday, February 12, 2015

C Program to print first 10 Prime numbers


#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,j,count=1,b=0;

cout<<"First Ten Prime Numbers Are

"<<"2";
for(i=3;i>0;++i)
{
for(j=2;j<=i;++j)
{
if(i%j==0)
b=1;
break;
}
if(b==0)
{
cout<<"
"<<i;
count++;

}
b=0;
if(count==10)
break;
}
getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.