Practice mode C Language

What is printed by this C code: printf(“%zu”, sizeof(long));?

Correct answer D. 8

Explanation

Linux and macOS on 64-bit hardware use the LP64 data model, where long and pointers are 64 bits (8 bytes) while int stays at 4 bytes. The tempting answer 4 is correct only on LLP64 systems such as 64-bit Windows. The C standard fixes only minimum ranges, so long must be at least 32 bits, and the actual size is platform dependent. Assume a typical 64-bit Linux or macOS system here.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.