HOME

Tuesday, March 24, 2015

C PROGRAM TO PRINT THE PRIME NUMBERS BETWEEN 1 AND N AS USER CHOICE


#include<stdio.h>
#inlcude<conio.h>
void main()
{
int num,i=1,j,count

clrscr();
printf("Enter Number value To Print Prime Numbers between 1 to Num: ");
scanf("%d",&num);
printf("Prime Numbers upto %d :\n \n",num);

while(i<=num)
{
count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2) 
printf("%d ",i);
i++;
}
printf("\n\n");


getch(); 
}

No comments:

Post a Comment