Skip to main content

Section 11.4 Practice with Formatting Options

Check Your Understanding Check Your Understanding

1.

What is the output of
printf("a = %05d\n", 35);
You should first think about this and try to figure out the answer by hand. Then feel free to use the window below to write a program to verify your answer. This time you have to write the entire program by yourself (hint: get started by copying and pasting from a previous program.)

admin.....open in new window

  • a = 00035
  • Correct
  • 35
  • Not quite. Try again!
  • 00035
  • Not quite. Try again!
  • a = 0535
  • Not quite. Try again!

2.

What happens when you use the format specifier %f to print out an integer? (feel free to write a short C program to try this out).

admin.....open in new window

  • The compiler will give a warning and output will most likely be incorrect.
  • Correct
  • No answer text provided.
  • Not quite. Try again!
  • The compiler will notice and abort the compilation with an error message.
  • Not quite. Try again!
  • The integer is automatically converted to a float and printed out correctly.
  • Not quite. Try again!