Difficulty: Easy
Correct Answer: Error
Explanation:
Introduction / Context:
This problem highlights type correctness in C: a string literal represents an array of characters, while a single char variable stores only one character. It also checks awareness that %s expects a char* (pointer to char), not a char value.
Given Data / Assumptions:
Concept / Approach:
char str = 'CuriousTab' is ill-formed; in standard C, multi-character constants like 'AB' are integer constants, but string literals use double quotes. Here double quotes are used, so assigning a string literal to char is a compilation error. Even if it compiled erroneously, printf('%s', str) would require a pointer, not a char, causing undefined behavior. Proper code would be either char str[] = 'CuriousTab'; or char str = 'CuriousTab';
Step-by-Step Solution:
Verification / Alternative check:
Change declaration to char str[] = 'CuriousTab'; and the program will print the word as expected.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing single characters (char) with strings (arrays/pointers to char) and mismatching printf format specifiers.
Final Answer:
Error.
Discussion & Comments