Difficulty: Medium
Correct Answer: Error
Explanation:
Introduction / Context:
This question checks your understanding of declarations, type qualifiers (const), and compilation rules in C. While many compilers offer extensions, a strictly conforming C compiler requires that every object declaration include a type. Printing behavior only matters if the code compiles, so the key concept is whether the declaration of c is valid C.
Given Data / Assumptions:
const c = -11;
(no explicit type).const int d = 34;
(valid).
Concept / Approach:
In ISO C, const
is a type qualifier that must qualify a complete type such as int
, double
, etc. A declaration like const c = -11;
omits the base type, making the declaration ill-formed and causing a compile-time error. Some historical or non-conforming modes might treat it as int
, but that is not guaranteed by the C standard.
Step-by-Step Solution:
const
appears without a type ⇒ invalid declaration. 2) The compiler reports a syntax or type error before linking or running. 3) Because compilation fails, no program output is produced.
Verification / Alternative check:
Try compiling with a standards-conforming mode (for example, enable ISO C warnings). The compiler will reject the declaration of c
. Changing it to const int c = -11;
makes the program valid and then the output would be -11, 34
.
Why Other Options Are Wrong:
-11, 34: Would only be correct if c
had a valid type, e.g., const int
.
11, 34: The sign would not flip; there is no operation that negates -11
.
None of these: The precise correct choice is “Error”.
Common Pitfalls:
const
implies int
by default—this is not guaranteed by the standard.
Final Answer:
Error
Discussion & Comments