BlackFriday 2024! 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 Topic 7 Question 95 Discussion

Actual exam question for C++ Institute's CPA exam
Question #: 95
Topic #: 7
[All CPA Questions]

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int min(int a, int b);

int main()

{

int b=10;

b = min(5,20);

cout << b;

return 0;

}

int min(int a, int b)

{

if (a

return(a);

else

return(b);

}

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Taryn
2 months ago
I think the correct answer is C) It prints: 5 because the function min will return the smaller number
upvoted 0 times
...
Krissy
2 months ago
Hmm, this is a tricky one. I'm going to have to think it through step-by-step. Let me see... *scratches head* Ah, I got it! It's C!
upvoted 0 times
Lovetta
1 months ago
Yeah, I agree with Lovetta. It should be 5.
upvoted 0 times
...
Naomi
1 months ago
I'm pretty sure it prints 5 as well.
upvoted 0 times
...
Josphine
1 months ago
No, I believe it prints 10.
upvoted 0 times
...
Kris
1 months ago
I think it prints 5.
upvoted 0 times
...
...
Denae
2 months ago
I'm not sure, but I think it might be A) It prints: 10
upvoted 0 times
...
Elza
2 months ago
Ha! This is a trick question. The code is printing the value of 'b', which is initially set to 10. So the answer must be A.
upvoted 0 times
...
Theresia
2 months ago
Wait, I'm a little confused. Isn't the 'min' function supposed to return the smaller of the two numbers? If that's the case, then the output should be 5. C it is!
upvoted 0 times
Catherin
1 months ago
So, the output should be 5.
upvoted 0 times
...
Margo
1 months ago
Yes, you're correct. The 'min' function returns the smaller of the two numbers.
upvoted 0 times
...
...
Ling
2 months ago
Okay, let me think about this. The 'min' function is comparing 5 and 20, so it should return 5. That means the output should be 5. I'm going with C.
upvoted 0 times
King
2 months ago
I agree, the output should be 5
upvoted 0 times
...
Marvel
2 months ago
I think it prints: 5
upvoted 0 times
...
...
Dominque
2 months ago
Hmm, this seems straightforward. The function 'min' should return the smaller of the two numbers, so I'm going with option C.
upvoted 0 times
Naomi
1 months ago
Yes, option C is the correct answer
upvoted 0 times
...
Kelvin
2 months ago
I agree, it should return the smaller number
upvoted 0 times
...
Eveline
2 months ago
I think it prints: 5
upvoted 0 times
...
...
Tesha
3 months ago
I agree with Margret, the function min will return the minimum of the two numbers
upvoted 0 times
...
Margret
3 months ago
I think the answer is C) It prints: 5
upvoted 0 times
...

Save Cancel