1) a. Write the C++ program that uses a recursive function to
print the elements of a list in reverse order.
b. Write the pseudocode for the program.
CODE IN C++:
#include <iostream>
using namespace std;
void print(int arr[],int n){
if(n==0)
return;
cout<<arr[n-1]<<" ";
print(arr,n-1);
}
int main()
{
int n;
cout<<"Enter the size of the array:";
cin>>n;
int arr[n];
int i;
cout<<"Enter the elements of the array:"<<endl;
for(i=0;i<n;i++){
cin >> arr[i];
}
cout<<"Displaying the elements of the array in reverse
order:"<<endl;
print(arr,n);
return 0;
}
OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.