Difficulty: Easy
Correct Answer: 1.2e2.0
Explanation:
Introduction / Context:This question checks the rules for writing floating-point constants in C using scientific notation (exponent form). The exponent part must be an integer (no decimal point), and there must be no spaces within the literal.
Given Data / Assumptions:
Concept / Approach:We compare each candidate with the lexical rules for C floating constants. Any deviation (for example, a non-integer exponent like '2.0') makes the token invalid. All valid forms must have an exponent consisting solely of optional sign followed by one or more decimal digits.
Step-by-Step Solution:
Check option a: '1.2e2.0' → exponent '2.0' is not an integer; invalid.Option b: '-2.3e-2' → valid (exponent is −2).Option c: '-2.3E2' → valid (uppercase E allowed; exponent 2).Option d: '-2.3e2' → valid (exponent 2).Option e: '3.0E+0' → valid (exponent +0).Verification / Alternative check:The C standard grammar for floating constants requires the exponent part to be an optionally signed sequence of digits; a decimal point in the exponent is illegal.
Why Other Options Are Wrong:
All others use an integer exponent and follow the allowed forms, so they are valid literals in C.Common Pitfalls:
Including spaces or decimal points inside the exponent; inserting a space splits tokens and makes them invalid.Final Answer:
1.2e2.0int range of −32768 to +32767)?
Discussion & Comments