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 CPP Exam - Topic 9 Question 120 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 120
Topic #: 9
[All CPP Questions]

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

#include

#include

using namespace std;

int main ()

{

float f = 10.126;

cout<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
Kayleigh
5 days ago
I practiced a similar question, and I think the output will show the float with two decimal places, so it might be B.
upvoted 0 times
...
Francoise
10 days ago
I remember something about setprecision affecting the output, but I can't recall if it rounds or just truncates the number.
upvoted 0 times
...
Linwood
15 days ago
I think the code should compile fine since there are no syntax errors, but I'm not sure about the output formatting.
upvoted 0 times
...

Save Cancel