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

I have a final in c++ on wednseday and I need some help with the following revie

ID: 3583238 • Letter: I

Question

I have a final in c++ on wednseday and I need some help with the following review questions.

17) What is the output of the following code if we call funRecurse(200)?
void funRecurse(int funParam)
{
cout<<"Hey, hey"<<endl;
if (funParam<41)
{
cout<< "Are you also"<<endl;
return;
}

funRecurse(funParam/5);//80 //*print line 1
cout<<"Sick of this"<<endl; //print line 2
funRecurse(funParam/20); //20 //print line 3
cout<<"Semester Too?"<<endl; //print line 4
}
}
18) Consider the following statements:
int i = 40;
int j = i+10;
int *p1;
int *p2;
int *p3
p1 = &i;
p2 = &j;
*p1 = *p2;
p3=p2;
p2=p1;
*p2=*p3;
cout << i << j << *p1 << *p2 << *p3<< endl;
Draw a diagram that represents what’s pointing to what at the end of the
code above and write what numbers are couted in the final statement.

Explanation / Answer

17

#include <iostream>
using namespace std;

void funRecurse(int);
int main() {
int funParam =200;
funRecurse(funParam);
   funRecurse(funParam/5);//40 //*print line 1
cout<<"Sick of this"<<endl; //print line 2
funRecurse(funParam/20); //10 //print line 3
cout<<"Semester Too?"<<endl; //print line 4

   return 0;
}
void funRecurse(int funParam)
{
cout<<"Hey, hey"<<endl;
if (funParam<41)
{
cout<< "Are you also"<<endl;

}
}

output:

Hey, hey
Hey, hey
Are you also
Sick of this
Hey, hey
Are you also
Semester Too?

18

#include <iostream>
using namespace std;


int main() {
int i = 40;
int j = i+10;
int *p1 = &i;
int *p2 =&j;
int *p3;

p1 = p2;
p3=p2;
p2=p1;
p2=p3;
cout << i <<" "<< j <<" "<< *p1 <<" "<< *p2 << " "<<*p3<< endl;

   return 0;
}

output:

40   50   50   50   50

i=40,j=50 ,*p1 =50,*p2=50,*p3 =50

50 ---> 50 <-- 50 p1 p2 p3