Joke Collection Website - Joke collection - OP jokes c language bosses

OP jokes c language bosses

The value of sizeof(2.5) is 8, so D is selected.

Sizeof is a C/C++ operator, which tests the number of bytes occupied by the type. It only takes the "type" of the expression in (), so sizeof(2.5)(2.5 can be any legal data with decimal point) is equivalent to sizeof(double) here.

According to C/C++, constants with decimal points default to double(8 bytes) instead of float(4 bytes), so the values of sizeof(2.5) and sizeof(double) are both 8.

If you want to make the floating-point constant float, you should follow the data with f or f, indicating that the floating-point constant is float. For example, if sizeof(2.5) here is written as sizeof(2.5f), then its value is 4.

At present, there are two common definitions of floating-point data in C/C++. One is float, which is represented by 4 bytes, and the other is double, which is represented by 8 bytes.