ProgrammingVery hard

printf("[%5s|%-5s]", "ab", "cd"); What is printed?

  1. A. [ cd|ab ]
  2. B. [ ba|cd ]
  3. C. [ ab|cd ]
  4. D. [ ab|dc ]

Correct answer: C. [ ab|cd ]

A plain width right-aligns and the minus flag left-aligns, so ab is padded on the left and cd on the right.

More C Programming questions

Exams that ask this topic