A prime number is a integer number greater than 1 and which number can be divided by 1 or itself .
Example :
2,3,5,7,11,13,17,19,23,29,31,37,41,43
Prime Number program In C :
Output :
Example :
2,3,5,7,11,13,17,19,23,29,31,37,41,43
Prime Number program In C :
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
do{
int a,b,flag=0;
clrscr();
printf("\tEnter a no (1-2000):");
scanf("%d",&a);
if(a<1 && a>2000)
{
exit(0);
}
for(b=2;b<a;b++)
{
if(a%b==0 )
{
flag=1;
break;
}
}
if(flag==0)
printf("\n\t<%d> is a prime no\n",a);
else
printf("\n\t<%d> is not a prime no\n",a);
printf("\n\tContinue(y/n):");
ch=getch();
}while(ch=='y'||ch=='Y');
}
Output :
If you have any Further Information and Quires about this Article don't hesitate to comment in comment box below.
AND
If you like this article , like our Facebook like page and click +1 to support 123techguide
|