If Any Required Program Please Ask In Comment I Will Help You(any Program in JAVA or C++) . . THANKS FOR VISITING MY BLOG!

If U LIKE MY PROFILE RAISE YOUR HAND IF U NOT RAISE UR STANDARD. Powered by Blogger.

Sunday, October 21, 2018

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