RECURSION IN C++

CODE:


#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<cstdlib>
using namespace std;
int random(int);
void main()
{
     int a;
     cout<<"\n Please enter how many random number you want to generate:";
     cin>>a;
     random(a);
     getch();

}

int random(int num)
{

     if(num<=0)
     {
           return 0;
     }
     cout<<"\n ==>> "<<rand();
     num--;
     random(num);

}

No comments:

Post a Comment