What is printed by this C code: printf(“%08.3f”, 3.14159);?
Correct answer B. 0003.142
Explanation
In %08.3f the precision .3 rounds to three decimals, giving 3.142, and the width 8 sets the minimum total field width, counting the digits and the decimal point. The 0 flag pads on the left with zeros instead of spaces, so four characters become 0003.142. Without a precision, %f prints six decimal places.
Answer checked How we write and check questions
Discussion