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

Replaces the \"XXXXs\" in the code below to complete the two functions. You shou

ID: 3534027 • Letter: R

Question

Replaces the "XXXXs" in the code below to complete the two functions.

You should repace the "XXXXXs" with some combination of:
       cout << *n << endl;
       recursivePrintForward(n+1, nCount-1);
       recursivePrintBackwards(n+1, nCount-1);
       if (nCount > 0){    }

////

#include <iostream>
using namespace std;

void recursivePrintForward(int *n, int nCount){
   // *n is a pointer to an array of ints
   // nCount is the number of items in the array
XXXX
XXXX
XXXX      
}

void recursivePrintBackwards(int *n, int nCount){
   // *n is a pointer to an array of ints
   // nCount is the number of items in the array
XXXX
XXXX
XXXX    
       
}

int main(){

   int numbers[] = {10,20,30,40,50,60,70,80,90};
   
   cout << "Testing recursivePrintForward:" << endl;
   recursivePrintForward(numbers,9);
   
    cout << "Testing recursivePrintBackwards:" << endl;
   recursivePrintBackwards(numbers,9);

   return 0;
}

Explanation / Answer

void recursivePrintForward(int *n, int nCount){

// *n is a pointer to an array of ints

// nCount is the number of items in the array

if (nCount==0)

{

return;

}

else

{

recursivePrintForward(n,nCount-1);

printf("%d",*(n+nCount-1));

}

  

}


void recursivePrintBackwards(int *n, int nCount){

// *n is a pointer to an array of ints

// nCount is the number of items in the array

  

if (nCount==0)

{

return;}

else{

recursivePrintBackwards((n+1),nCount-1);

printf("%d",*n);

}

}