Question 1
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
printf("%6.2f|%-4d|%04d|%+d\n", 3.14159, 7, 42, 5);
return 0;
}
- A 3.14|7 |0042|+5 Correct
- B 3.14 | 7|0042|+5
- C 3.14|7 |4200|5
- D 3.14|7|42|+5
Correct Answer: Option A
Width 6 with 2 decimals right-aligns 3.14 in 6 columns; - left-aligns 7 in 4; 0 pads 42 with zeros to 4; + shows the sign.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!