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

The correct answer for the following questions are E,C,B,B. Can you explain them

ID: 3606775 • Letter: T

Question

The correct answer for the following questions are E,C,B,B. Can you explain them for me.

void decision(int &, int );
int main ( )
{
int x = 0;
int y = 3;
decision(x, y);
return 0;
}
void decision(int &a, int b)
{
if(a = 1)
cout<<a;
else if (b == 3)
cout<<b;
if(b == 2)
cout<< “Not 2”;
cout<< “Done”;
}

8. What does this code output?
a. 123 d. 03Done
b. 132 e. 1Done
c. 3 Not 2
9. How many cout statements are executed?
a. 3 d. 0
b. 1 e. 4
c. 2
10. The values of x and y after the function call are?
a. x = 0 and y = 2 d. x = 1 and y = 2
b. x = 1 and y = 3 e. x = 0 and y = 3
c. x = 0 and y = 2
11. None of the values passed to the function change.
a. True b. False

Explanation / Answer

8.) first statement in if assigns a with value 1 and condition will become true. Therefore it will print value of a which is 1, Since condition in if block evaluates to true condition in elseif will not be checked and Done will print obviously.

9.) 2 cout statements will execute. One which is displaying a and another which is displaying done as explained previously.

10.) value of x is passed as reference. therefore any change in a will reflect on x. Therefore value of x will become 1 and value of y will not change.

11.) Since value of x is passed as reference. therefore value of x will be altered

Hope it helps, do give your valuable response.

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