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 << mul(1) << mul(2,4);
return 0;
}
Suggested Answer: A
Get Premium CPA-21-02 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
32 comments · newest first
ME
Melinda
11 months ago
The default parameter really changes things!
BR
Brandon
11 months ago
I thought it would be 8, not 6.
SH
Shalon
11 months ago
Wait, how does it get 6?
JE
Jean
11 months ago
Totally agree, that's the right output!
BI
Billy
11 months ago
It prints: 6
PE
Percy
12 months ago
I feel like the output should be 6 because mul(1) gives 2 and mul(2, 4) gives 8, but I might be mixing things up.
TR
Tracey
12 months ago
I practiced a similar question, and I think the total output would be 2 + 8, which makes 10, but that’s not an option here.
NA
Nada
12 months ago
I'm not entirely sure, but I think the second call mul(2, 4) would multiply 2 by 4, giving 8.
EF
Effie
1 year ago
I remember that default parameters can be tricky. I think mul(1) would use the default value of 2, so that would be 1 * 2.
LU
Luz
1 year ago
Wait, I'm not sure about that. Let me double-check the logic here. I don't want to make any assumptions.
TA
Tamekia
1 year ago
I'm feeling pretty confident about this one. The output should be 2 and 8, for a total of 10.
MA
Marshall
1 year ago
Okay, I think I've got this. The first call to mul() will use the default parameter of 2, and the second call will use the explicit parameter of 4.
TO
Tonja
1 year ago
Hmm, I'm a bit confused by the default parameter in the function. I'll need to make sure I understand how that works.
NO
Norah
1 year ago
This looks like a tricky one. I'll need to carefully read through the code and think through the function calls.
BR
Britt
1 year ago
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.
JA
Jamal
1 year ago
Hmm, let's see... if the default parameter is 2, does that mean the function is called 'mul'? I bet the real answer is 'divide'! *wink wink*
EL
Elenora
1 year ago
It prints: 2 8
EL
Elenora
1 year ago
The default parameter is 2, so it multiplies the values.
EL
Elenora
1 year ago
No, the function is called 'mul' not 'divide'.
RO
Ronna
1 year ago
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!
BA
Bambi
1 year ago
Yes, the default parameter kicks in for the first call to mul.
GL
Glory
1 year ago
I think you're right, it should print 2 and 8.
TR
Truman
2 years ago
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!
RE
Refugia
2 years ago
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.
RO
Roslyn
1 year ago
When you add them up, it prints 8.
JO
Jose
1 year ago
So 'mul(1)' returns 2 and 'mul(2,4)' returns 8.
RA
Raul
1 year ago
Yes, that's correct! The default parameter is 2 in the 'mul' function.
JA
Jani
1 year ago
I think the answer is C) It prints: 8
FA
Fatima
2 years ago
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.
FA
Fairy
2 years ago
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.
ME
Merri
2 years ago
I disagree, I believe the answer is C) It prints: 8.
FA
Fairy
2 years ago
I think the answer is B) It prints: 28.