Machine-translated by Google. Questions are authored in English.
Top

Discussion

By default, any real number in 'C' is treated as

  • A.A float
  • B.A double
  • C.A long double
  • D.Depend upon memory model that you are using

Answer: B

Correct answer: A double

An unsuffixed floating constant such as 3.14 has type double in C. To obtain a float the suffix f is required - 3.14f - and L gives a long double.

The default matters in arithmetic: writing float x = 1.0/3.0; performs the division in double precision and only then narrows the result, which is usually what is wanted. It also matters for performance on hardware where single precision is faster, since the double constant forces the whole expression up.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.