C Source Codes List | Source Code Home
Program : Program for finding the prime numbers.
/* Program for finding the prime numbers */
#include
#include
void main()
{
int n,m,k,i,max;
char c;
clrscr();
printf("\t\t\tWELCOME TO THE PROGRAM SIR/MADAM\n\n");
repeat: max=0;
k=2;
n=1;
printf("You want prime numbers upto:- ");
scanf("%d",&max);
printf("\n\n");
for (i=1;i<=max;i++)
{
again: m=(n/k)*k;
if (m!=n)
k=k+1;
else
goto try1;
if (k < n/2)
goto again;
else
printf("%d",n);
printf(" ");
try1: n=n+1;
k=2;
}
fflush(stdin);
printf ("\n\nDo you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
printf("\n\n\n\n\n\t\t\tHAVE A NICE DAY! BYE.");
getch();
}
C Source Codes List | Source Code Home
|
|