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 Topic 5 Question 93 Discussion

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

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

#include

using namespace std;

int op(int x, int y);

int main()

{

float *pf;

float f=0.9;

pf=&f;

cout << op(1, *pf);

return 0;

}

int op(int x, int y)

{

return x*y;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Willetta
8 months ago
I'm going with D) It prints: to. Surely, the swap() function will only affect the first two elements, and the rest will be ignored, right?
upvoted 0 times
Lynelle
8 months ago
Yeah, I agree. The swap() function only affects the first two elements.
upvoted 0 times
...
Fabiola
8 months ago
I think it prints: to
upvoted 0 times
...
...
Abel
8 months ago
Haha, this question is a classic! The answer is clearly B) It prints: toHow. Swapping the elements of a string array is like a magic trick, isn't it?
upvoted 0 times
...
Deandrea
9 months ago
I think the answer is A) It prints: Hoto. The swap() function will swap the elements of the string array, but the output will be concatenated.
upvoted 0 times
Alfreda
8 months ago
Oh, I see. Thanks for clarifying!
upvoted 0 times
...
Blair
8 months ago
No, it actually prints: toHow.
upvoted 0 times
...
Jacqueline
8 months ago
I think the answer is A) It prints: Hoto.
upvoted 0 times
...
...
Kris
9 months ago
I think it prints: toHow because the swap function swaps the elements at index 0 and 1
upvoted 0 times
...
Magda
9 months ago
The correct answer is B) It prints: toHow. The swap() function will swap the elements of the string array, so the output will be reversed.
upvoted 0 times
Frank
8 months ago
Oh, I see. Thanks for clarifying!
upvoted 0 times
...
Deandrea
8 months ago
Actually, it prints: toHow
upvoted 0 times
...
Tijuana
8 months ago
No, I believe it prints: Hoto
upvoted 0 times
...
Dahlia
8 months ago
I think the answer is B) It prints: toHow
upvoted 0 times
...
...
Fernanda
9 months ago
I'm not sure, but I think it prints: toHow as well
upvoted 0 times
...
Brice
9 months ago
I believe it prints: toHow because the swap function swaps the elements in the array
upvoted 0 times
...
Long
9 months ago
I think it prints: toHow
upvoted 0 times
...

Save Cancel