PRINT ARRAY ELEMENTS IN REVERSE ORDER using RECURSION.
#include <iostream>>
#include <conio.h>
using namespace std;
int Reverse(int *Arr, int No);
int main()
{
int Size = 10;
int *Arr = new int[Size];
cout << "Enter Elements Of Array is: " << endl;
for(int I =1; I <=Size; I++)
{
Arr[I] = I;
cout << Arr[I] << endl;
}
cout << "\nThis Function Returning Value: " << Reverse(Arr, Size) << endl;
getch();
return 0;
}
int Reverse(int *Arr, int No)
{
if(No <= 0)
return 1;
cout << "Index No: "<< No << " Value: " << Arr[No] << endl;
return Reverse(Arr, No -1) ;
}
0 comments:
Post a Comment