Difficulty: Easy
Correct Answer: K
Explanation:
Introduction / Context:printf uses a format string to control how subsequent arguments are printed. With the "%s" format, printf expects a pointer to a null-terminated string. This question checks whether you can trace a simple printf call passing a one-character string with a newline.
Given Data / Assumptions:
Concept / Approach:The "%s" format prints characters from the provided char until the terminating '\0'. Therefore, the two characters 'K' and '' are emitted. Many MCQs capture the visible part (“K”) and ignore that a newline follows; here the important visual output is the letter K followed by a line break.
Step-by-Step Solution:
printf("%s", "K")Output sequence → 'K' then newline.On a terminal, you see K and the cursor moves to the next line.Verification / Alternative check:Change the literal to "K" (no newline) to see the cursor remain on the same line.
Why Other Options Are Wrong:
Error/No output: printf is called correctly with a matching argument type.%s: That would print the percent-escaped letters literally, which does not happen here.K%s: Not produced by printf for this call.Common Pitfalls:Forgetting the newline is part of the literal; misreading the format string as a literal to be printed rather than a directive.
Final Answer:K.
Discussion & Comments