Q. Which of the following is the correct datatype for the variable n in the statement given below?
n = 35.29 ;
β
Correct Answer: (A)
float
Explanation:
- In C language, implicit typing depends on the context.
- The value 35.29 is a double literal by default in C.
- However, the datatype of n will depend on how it's declared.
Cases:
- If n is declared as float β n = 35.29; will store it as a single-precision floating-point number.
- If n is declared as double β It remains a double (default for floating-point literals in C).
- If n is declared as long double β The value will be promoted to long double (extended precision, depending on the system).