A

Akash Lawaniya • 9.58K Points
Tutor III

Q. Which of the following is the correct datatype for the variable n in the statement given below?
n = 35.29 ;

  • (A) float
  • (B) double
  • (C) long double
  • (D) Depends upon the memory model that you are using

Explanation by: Mr. Dubey

 

  • 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:

  1. If n is declared as float → n = 35.29; will store it as a single-precision floating-point number.
  2. If n is declared as double → It remains a double (default for floating-point literals in C).
  3. If n is declared as long double → The value will be promoted to long double (extended precision, depending on the system).

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics