Q. What is the size of float in a 32-bit compiler?

  • (A) 8
  • (B) 4
  • (C) 2
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4
Explanation:

In a 32-bit compiler, the size of a float data type is 4 bytes (32 bits) because:

  • A float in C follows the IEEE 754 single-precision floating-point standard, which uses:
    • 1 bit for the sign
    • 8 bits for the exponent
    • 23 bits for the mantissa (fraction)

Verification with C Code:

You can check the size of float using:

#include <stdio.h>
int main() {
printf("Size of float: %zu bytes\n", sizeof(float));
return 0;
}

Output:

Size of float: 4 bytes

Final Answer:

βœ… (B) 4

Explanation by: Mr. Dubey

In a 32-bit compiler, the size of a float data type is 4 bytes (32 bits) because:

  • A float in C follows the IEEE 754 single-precision floating-point standard, which uses:
    • 1 bit for the sign
    • 8 bits for the exponent
    • 23 bits for the mantissa (fraction)

Verification with C Code:

You can check the size of float using:

#include <stdio.h>
int main() {
printf("Size of float: %zu bytes\n", sizeof(float));
return 0;
}

Output:

Size of float: 4 bytes

Final Answer:

βœ… (B) 4

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
263
Total Visits
πŸ“½οΈ
5 y ago
Published
πŸŽ–οΈ
Akash Lawaniya
Publisher
πŸ“ˆ
83%
Success Rate