ProgrammingHardProduct company OA

Assume 4-byte float and 8-byte double. What is printed?

Assume 4-byte float and 8-byte double. What is printed?
#define PI 3.14
printf("%zu %zu", sizeof(PI), sizeof(PI * 2.0f));
  1. A. 8 8
  2. B. 8 4
  3. C. 4 8
  4. D. 4 4

Correct answer: A. 8 8

An unsuffixed floating constant such as 3.14 has type double (3.14f would be float). In PI * 2.0f the float is converted to double by the usual arithmetic conversions, so both expressions are double: 8 and 8.

More C Programming questions

Exams that ask this topic