C program to display N prime numbers
/*************************************************************
C program to display N prime numbers
***********************************************************/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,count=0,num;
clrscr();
printf("Enter number up to which you want to display prime numbers\n");
scanf("%d",&n);
printf("The prime numbers up to %d are \n",n);
for(num=1;num<=n;num++)
{
count=0;
for(i=1;i<=num;i++)
{
if(num%i==0)
{
count++;
}
}
if(count==2)
printf("%d\t",num);
}
printf("\nEnd of program");
getch();
}
Enter number up to which you want to display prime numbers
30
The prime numbers up to 30 are
2 3 5 7 11 13 17 19 23 29
End of program
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏