Practice mode C Language

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.