C Program Prime Number
/* Write a program to print first N prime numbers. ( no factor other than 1 & itself) */
#include <stdio.h>
int main(void) {
int n,i,no=2;
printf("How many Prime Number You Want : ");
scanf("%d",&n);
while(n>0)
{
i=2;
while(i<no)
{
if(no%i==0)
{
break;
}
i++;
}
if(no==i)
{
printf(" %d",i);
n--;
}
no++;
}
return 0;
}
#include <stdio.h>
int main(void) {
int n,i,no=2;
printf("How many Prime Number You Want : ");
scanf("%d",&n);
while(n>0)
{
i=2;
while(i<no)
{
if(no%i==0)
{
break;
}
i++;
}
if(no==i)
{
printf(" %d",i);
n--;
}
no++;
}
return 0;
}
Comments
Post a Comment