0% found this document useful (0 votes)
49 views2 pages

Chapter 4 Floating Point Issues

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

Chapter 4 Floating Point Issues

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Chapter 4: Floating Point Issues - Question Paper

Section A: Multiple Choice Questions (MCQs) [1 Mark Each]


1. Which data type is used for floating-point numbers in C?
a) int
b) float
c) char
d) double

2. What is the size of a float in most C compilers?


a) 2 bytes
b) 4 bytes
c) 8 bytes
d) 16 bytes

3. Which of the following can store the highest precision floating-point numbers?
a) float
b) double
c) long double
d) int

4. Floating-point numbers are represented in memory using:


a) ASCII encoding
b) Binary representation
c) Decimal representation
d) Hexadecimal encoding

5. What will be the output of printf("%f", 0.1 + 0.2)?


a) 0.3
b) 0.300000
c) A value slightly different from 0.3
d) Compilation Error

Section B: Fill in the Blanks [1 Mark Each]


6. The IEEE 754 standard is used for representing ______ numbers in computers.
7. A ______ in floating-point arithmetic occurs when a number is too large to be represented.
8. The function used to round a floating-point number in C is ______.
9. The floating-point precision issue arises due to the limited number of ______ available for
storage.
10. The ______ format is commonly used for double-precision floating-point representation.

Section C: True or False [1 Mark Each]


11. Floating-point arithmetic is always precise in C.
12. The float data type provides more precision than double.
13. Floating-point operations can produce rounding errors.
14. The printf function can be used to control the precision of floating-point output.
15. Overflow and underflow issues are common in floating-point arithmetic.

Section D: Short Answer Questions [2 Marks Each]


16. What is the difference between float, double, and long double?
17. Explain why floating-point numbers cannot always be represented precisely.
18. How does the IEEE 754 standard represent floating-point numbers?
19. Why do floating-point calculations sometimes produce unexpected results?
20. How can you format a floating-point number to display only two decimal places in C?

Section E: Coding Questions [5 Marks Each]


21. Write a C program to demonstrate floating-point precision errors.
22. Implement a program to compare two floating-point numbers correctly.
23. Write a program to round a floating-point number to two decimal places.
24. Create a program to convert a floating-point number to scientific notation.
25. Implement a program to check if a given floating-point number is normalized in IEEE 754
representation.

You might also like