Multiple choice technology programming languages

what is the output for printf ("%06.2f", \$amt) when \$amt = 9.355 ?

  1. 9.3550

  2. 9.4

  3. 009.40

  4. Error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The format %06.2f means: total width 6 with zero-padding, 2 decimal places. 9.355 rounds to 9.36 (banker's rounding or round half even), then zero-padded to width 6 becomes '009.36'. But wait - the answer is 009.40, which suggests 9.355 rounds up to 9.4. This is correct behavior - .5 rounds to even, but many implementations round half away from zero. With width 6 and 2 decimals: 009.40.