OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

What will be the output of the code given below?

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

What will be the output of the code given below?

printf("ab", "cd", "ef");a

**MCQ

Choose one option.
Show answer & explanation
Answer: D. ab

The printf() function interprets its first argument as a format string. Since "ab" contains no format specifiers (like %s, %d, etc.), it is printed literally. The additional arguments "cd" and "ef" are passed but ignored because there are no corresponding format specifiers to consume them. Therefore, only "ab" is printed.

Step-by-step Derivation:
Step-by-step execution:

  1. printf() is called with three string arguments: "ab", "cd", "ef"
  2. The first argument "ab" is the format string
  3. The format string "ab" contains no format specifiers (no % characters)
  4. Since there are no format specifiers, printf() simply outputs the format string as-is: "ab"
  5. The extra arguments "cd" and "ef" are ignored—they are never accessed or used
  6. Output: ab