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
πŸ’¬ Discuss
βœ… 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:

  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).
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).

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
283
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Akash Lawaniya
Publisher
πŸ“ˆ
89%
Success Rate