Sunday, October 16, 2011

Prime Number Series

#include<conio.h>

#include <stdio.h>

void main()
{
        int n,i,j,ch;
        clrscr();
        printf(“Enter The Last Number in the Series: “);
        scanf(“%d”,&n);
        printf(“\n\nThe Prime Number Series Between 1 to %d :”,n);
        for(i=1;i<=n;i++)
        {
              ch=1;
              for(j=1;j<i;j++)
             {
                    if(j%i==0)
                    ch=0;
             }
             if(ch!= 0)
             printf(“\n%d\t”,i);
        }
getch();
}

No comments:

Post a Comment