Thursday, 9 February 2012

print prime no between up to n????

#include<stdio.h>
#include<conio.h>
void main()
{
            // print prime no
            int i,j,s,e,c=0,n;
            clrscr();
             printf("enter starting no\n");
             scanf("%d",&s);
             printf("enter ending no\n");
             scanf("%d",&e);
             if (s<e)
               {
                       for(j=s;j<=e;j++)
                          {
                               c=0;
                                      for(i=1;i<=j;i++)
                                         {
                                                if(j%i==0)
                                                   {
                                                          c++;
                                                    }
                                          }
                                            if(c==2)
                                             {
                                                     printf("\n%d",j);
                                             }
                            }
                             getch();
    }

No comments:

Post a Comment