Written by Dinesh Thakur

 

void main()

{
         int a[100],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;
                       }
      }

First N Prime Number using Recursion





About Us

Dinesh ThakurDinesh Thakur is a Columinist and designer with strong passion and founder of Computer Notes. if you have any ideas or any request me @
linkedin FaceBook Twitter Google Plus