Pages

Visitors

2603

Sunday, 25 December 2011

Prime numbers! :D


#include<stdio.h>
#include<conio.h>

void main()
{
    int num,i,j,temp;

    printf("enter range : ");

    scanf("%d",&num);

    printf("The Prime numbers between 1 and %d are : \n",num);

    printf("1\n");

    for (i=2;i<=num;i++)

    {
        temp = i;

        for (j=2;j<=temp;j++)

        {
            if(temp%j==0)

            break;

        }

        if(temp==j)

        printf("%d\n",temp);
    }

    getch();

    }

No comments:

Post a Comment