Which of the following has compilation error in C ?
2013
Which of the following has compilation error in C ?
- A.
int n = 32 ;
- B.
char ch = 65 ;
- C.
float f = (float) 3.2 ;
- D.
none of the above
Attempted by 1387 students.
Show answer & explanation
Correct answer: D
Answer: none of the above
Explanation:
int n = 32 ; — Declares an integer variable and initializes it with the integer literal 32. This is valid and compiles.
char ch = 65 ; — The integer literal 65 is converted to type char during initialization. Implicit conversion from an integer literal to char is allowed, so this compiles.
float f = (float) 3.2 ; — The literal 3.2 is a double by default; casting it to float produces a float value and the initialization is valid. This compiles.
Therefore, none of the given declarations cause a compilation error in standard C.