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 1 Question 15 Discussion

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

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

#include

using namespace std;

int op(int x, int y);

float op(int x, float y);

int main()

{

int i=1, j=2, k;

float f=0.3;

k = op(i, j);

cout<< k << "," << op(0, f);

return 0;

}

int op(int x, int y)

{

return x+y;

}

float op(int x, float y)

{

return x?y;

}

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Ashton
4 hours ago
This code has a problem with the second op function. The return statement 'x?y' is not valid C++ syntax. I think the correct answer is B) It prints: 3,?0.3.
upvoted 0 times
...
Evette
3 days ago
The output should be 3,0.3. The first call to op(i, j) will return the sum of i and j, which is 3. The second call to op(0, f) will return 0.3, since the first parameter is an integer and the second parameter is a float.
upvoted 0 times
...
Vivienne
4 days ago
But the second function returns x?y, which means it will return 0.3 if x is not 0. So, I still think it's A)
upvoted 0 times
...
Cory
7 days ago
I disagree, I believe the answer is B) It prints: 3,?0.3
upvoted 0 times
...
Vivienne
12 days ago
I think the answer is A) It prints: 3,1
upvoted 0 times
...

Save Cancel