/*
Name: WAP to generate the prime numbers
Author: Parveen Malik
Date: 18/09/11 01:14
*/
#include<stdio.h>
#include<conio.h>
int main(void)
{
int i,num,x,flag;
printf("Enter the value upto which prime numbers is to be generated : ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
x=2;
flag=0;
while(x<=i/2)
{
if(i%x==0)
{
flag=1;
break;
}
x++;
}
if(flag==0)
printf("%5d",i);
}
getch();
return 0;
}
OUTPUT :
0 comments:
Post a Comment