Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 5 Question 25 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 25
Topic #: 5
[All CPA-21-02 Questions]

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;

}

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Jamal
7 days 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*
upvoted 0 times
...
Ronna
9 days 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!
upvoted 0 times
...
Truman
14 days 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!
upvoted 0 times
...
Refugia
15 days 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.
upvoted 0 times
Raul
2 days ago
Yes, that's correct! The default parameter is 2 in the 'mul' function.
upvoted 0 times
...
Jani
4 days ago
I think the answer is C) It prints: 8
upvoted 0 times
...
...
Fatima
16 days 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.
upvoted 0 times
...
Fairy
22 days 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.
upvoted 0 times
...
Merri
24 days ago
I disagree, I believe the answer is C) It prints: 8.
upvoted 0 times
...
Fairy
25 days ago
I think the answer is B) It prints: 28.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77