Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write arecursive function that takes three arguments (an integer array,starting

ID: 3618830 • Letter: W

Question

Write arecursive function that takes three arguments (an integer array,starting subscript ‘s’ and

endingsubscript ‘e’ ).

In firstrecursive call, the function should display the array fromsubscript ‘s’ (s = 0) to ‘e’ (e=

size ofarray). In each successive call, the function should print thearray from index s+1 to e. The

functionshould stop processing and return when starting subscript becomesequal to ending

subscript.

For example,if user enters values for array 2, 3, 4, 5, 6 then the recursivefunction must display

the followingoutput.

2 3 4 56

3 4 56

4 56

56

6

Explanation / Answer

#include<iostream.h> #include<conio.h> void recursive(int [],int,int); void main() {    int array[5];    for(int i=0;i<5;i++)    {    cout<<" Enter the"<<i<<" Index number :";    cin>>array[i];    }    recursive(array,0,4); //0 is thestarting index and 4 is the ending subscript    getche(); } void recursive(int arr[],int s,int e) {    if(s!=e+1)    {    for(inti=s;i<=e;i++)      cout<<arr[i]<<" ";;
   cout<<endl;    s++;    recursive(arr,s,e);    //Recursivecall    } }      
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote