DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

To Find The Prime Number.

04.03.2012
| 2311 views |
  • submit to reddit
        // description of your code here

{
int a,b;
printf("enter the starting no:\t");
scanf("%d",&a);
printf("enter the final no:\t");
scanf("%d",&b);
clrscr();
printf("The Prime Numbers Are\n");
for(a;a<=b;a++)
{
if(a%2)
{
printf("%d",a);
}
}
getch();
}

Regards'
<a href="http://www.searchmechaniks.co.uk/link-building/">Link building uk</a>
    

Comments

Snippets Manager replied on Thu, 2012/04/05 - 9:54pm

{ int a,b; int i,j; printf("enter the starting no:\t"); scanf("%d",&a); printf("enter the final no:\t"); scanf("%d",&b); clrscr(); printf("The Prime Numbers Are\n"); for(a;a<=b;a++) { if(a%2) { j=(int)sqrt(a); ; for(i=3; i<=j; i+=2) if(a%i==0)break; if(i>j)printf("%d",a); } } }