Given below are 3 lines of code. Select the options given below with respect to the syntactical correctness regarding both C and C++? [code] sho

Given below are 3 lines of code. Select the options given below with respect to the syntactical correctness regarding both C and C++?
Code:
short x = 200;
int b = (int) a;
int c = int (a);
A. Lines 1 and 2 are incorrect
B. Lines 2 and 3 are incorrect
C. Only line 1 is incorrect
D. No lines are incorrect
 
Answer: D
Explanation: In the code snippet given above, none of the lines are incorrect. Lines 2 and 3 exhibit the explicit type casting method for both C-Like cast notation and functional notation respectively, while line 1 simply declares and initiates a variable x of the short data type and value of 200.
 

Tìm kiếm

Back
Top