# C Program Print First N Prime Number using Recursion

by Dinesh Thakur Category: C Programming (Pratical)

In this program required variable are declared for functioning criteria. Then using loop statement for fulfilling the requirement of repeat the process. Then to use if condition to check whether the number is prime or not. After finding the prime number the next process is to elaborate them using while statement or if condition if number division able by declare value then break the statement else it will increase the value for variable and then if (y==x) then return the value as required.

Problem statement:-
This program is an implementation about to print first N prime number using recursion function.

1. Declaring Variable as required.
2. Using required function or statements.
3. Display result on the screen.

This C program is successfully compiled and run on a System. Output is shown below.

```void main(){         int a,i,j,k,n,b;         int prime(int);         clrscr();         printf("Enter no of elements : ");         scanf("%d",&n);         printf("Enter a no : ");         for(i=0;i<n;i++)             {                                 scanf("%d",&a[i]);             }                for(i=0;i<n;i++)                    {                        b=prime(a[i]);                        if(b==a[i])                         {                              printf("Prime Number is : %d\n",a[i]);                         }                   }                             getch();}            int prime(int x)       {             int y=2;             while(y<100)                   {                       if(x%y==0)                         {                             break;                         }                      else                        {                             y=y++;                        }                  }                      if(y==x)                       {                              return x;                       }      }
``` Related Articles on C Programming Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.