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 3 Question 34 Discussion

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

What is the output of the program given below?

#include

using namespace std;

int main (int argc, const char * argv[])

{

float f=?10.501;

cout<<(int)f;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Jennifer
1 months ago
This is a simple case of rounding. The float f is 10.501, and when we cast it to an integer, it should round up to 11. Option B is the correct answer, no doubt about it.
upvoted 0 times
...
Emilio
1 months ago
Haha, the question mark is just there to confuse us. It's a classic trick question! I'm going to go with option D, because who doesn't love a bit of chaos in their code?
upvoted 0 times
Helaine
15 days ago
I think it's option C, the output will be ?10.
upvoted 0 times
...
...
Louisa
2 months ago
Wait, why is the float initialized with a question mark? That's not valid syntax! I'm going to go with option C, which seems to make the most sense.
upvoted 0 times
Sherell
4 days ago
I agree with you, option C seems like the correct answer.
upvoted 0 times
...
Rhea
14 days ago
I'm not sure about that. I believe it will be 11.
upvoted 0 times
...
Candra
18 days ago
That's a tricky one. I think the output will be 10.
upvoted 0 times
...
...
Marva
2 months ago
I think the output will be 11. The float f is initialized to 10.501, and when we cast it to an integer, the decimal part gets truncated.
upvoted 0 times
...
Shawna
2 months ago
But since it's casting a float to an int, it will truncate the decimal part, so the output should be 10.
upvoted 0 times
...
Harris
2 months ago
I believe the output will be 11.
upvoted 0 times
...
Shawna
2 months ago
I think the output will be 10.
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