Difficulty: Easy
Correct Answer: printf("\n");
Explanation:
Introduction / Context:
Escape sequences in C string literals can be confusing. The backslash introduces special sequences like (newline). To print a backslash character itself, you must escape it as \\ in the source to produce a single backslash at runtime. This question asks for the exact printf form to display the text literally, not to create a newline.
Given Data / Assumptions:
Concept / Approach:
In C string literals, "\" represents a single backslash character. Therefore, "" in a literal results in two output characters: backslash and n. Passing that literal to printf prints exactly as text. Using '' (single quotes) forms a character literal representing newline, not the two-character sequence.
Step-by-Step Solution:
Write a string literal that encodes backslash: "\".Append the character n to form "".Call printf(""); to print those two characters.Do not use character literals or unescaped backslashes.
Verification / Alternative check:
Running printf(""); produces backslash-n on the console. Running printf("\"); would print two backslashes followed by n (i.e., \).
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting that backslash must be escaped in string literals. Confusing character and string literals leads to different behavior.
Final Answer:
printf("");.
Discussion & Comments