C++ Institute CPA-21-02 Exam - Topic 5 Question 25 Discussion
What happens when you attempt to compile and run the following code?#include using namespace std;int mul (int a, int b=2){int r;r=a*b;return (r);}int main (){cout
A) It prints: 2
B) It prints: 28
C) It prints: 8
D) It prints: 6
C++ Institute CPA-21-02 Exam - Topic 5 Question 25 Discussion
Actual exam question for
C++ Institute's
CPA-21-02 exam
Hmm, I'm a bit unsure about this one. I know the SLA is important, but I'm not totally clear on what the auditor's main goal should be. I'll need to review the details of the question and think through the different options carefully.
Aha, I know this one! The default parameter in 'mul' is 2, so 'mul(1)' will give us 2. And 'mul(2,4)' will give us 8. Therefore, the answer is A) It prints: 2. Easy peasy!
Wait, wait, wait... I think I got this. The default parameter in 'mul' is 2, so 'mul(1)' will give us 2. And 'mul(2,4)' will give us 8. Putting them together, the answer must be B) It prints: 28. Nailed it!
This is easy! The default parameter in the 'mul' function is 2, so 'mul(1)' will return 2. Then 'mul(2,4)' will return 8. Add them up, and the answer is C) It prints: 8.
Hmm, let's see... if the default value for the second parameter in the 'mul' function is 2, then calling 'mul(1)' should give us 2. And 'mul(2,4)' should give us 8. So the answer must be D) It prints: 6.
But if you look at the code, when mul(1) is called, it uses the default value of b which is 2, so it should be 1*2=2. And when mul(2,4) is called, it should be 2*4=8. So the answer should be B) It prints: 28.
Melinda
9 months agoBrandon
9 months agoShalon
9 months agoJean
10 months agoBilly
10 months agoPercy
10 months agoTracey
10 months agoNada
10 months agoEffie
11 months agoLuz
11 months agoTamekia
11 months agoMarshall
11 months agoTonja
11 months agoNorah
11 months agoBritt
11 months agoJamal
1 year agoElenora
1 year agoElenora
1 year agoElenora
1 year agoRonna
1 year agoBambi
1 year agoGlory
1 year agoTruman
1 year agoRefugia
1 year agoRoslyn
1 year agoJose
1 year agoRaul
1 year agoJani
1 year agoFatima
1 year agoFairy
1 year agoMerri
1 year agoFairy
1 year ago