Program to find the prime number in c-langauge
In this program we will now find all the n prime number where value n is entered by the user by using function in c-programming.
#include<stdio.h>
#include<conio.h>
void prime(int );
void main()
{
int n;
printf("enter the number:-");
scanf("%d",&n);
prime(n);
getch();
}
void prime(int x)
{
int i,j,count=0;
for(i=1;i<x;i++){
for(j=2;j<i;j++){
if(i%j==0)
break;
}
if(i==j)
printf("%d ",i);
}
}
output:-

No comments:
Post a Comment