C- Floating Point Issues MCQ Questions and Answers
Handling floating-point numbers in C can be tricky due to precision limits, rounding errors, and data representation issues. This section on C Floating Point Issues questions with answers is designed to help you master these concepts effectively. In interviews and placement tests by Infosys, TCS, and Wipro, such questions are commonly asked to test your understanding of floating-point arithmetic and memory storage. Practicing C programming MCQs on this topic will improve your accuracy in calculations and code debugging. Each question includes detailed reasoning to clarify why floating-point comparisons or conversions behave unexpectedly. Strengthen your programming foundation and get ready for technical assessments with this comprehensive guide.
C- Floating Point Issues MCQ
1. What are the different types of real data type in C ?
- float, double
- short int, double, long int
- float, double, long double
- double, long int, float
2. What will you do to treat the constant 3.14 as a long double?
- use 3.14LD
- use 3.14L
- use 3.14DL
- use 3.14LF
3. Which statement will you add in the following program to work it correctly? #include<stdio.h> int main() { printf("%f\n", log(36.0)); return 0; }
- #include<conio.h>
- #include<math.h>
- #include<stdlib.h>
- #include<dos.h>
4. We want to round off x, a float, to an int value, The correct way to do is
- y = (int)(x + 0.5)
- y = int(x + 0.5)
- y = (int)x + 0.5
- y = (int)((int)x + 0.5)
6. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?
- ABCD
- DCBA
- 0xABCD
- Depends on big endian or little endian architecture
7. What will you do to treat the constant 3.14 as a float?
- use float(3.14f)
- use 3.14f
- use f(3.14)
- use (f)(3.14)
8. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
- rem = (5.5 % 1.3)
- rem = modf(5.5, 1.3)
- rem = fmod(5.5, 1.3)
- Error: we can't divide
9. What is the primary reason for floating-point representation errors in computing?
- Limited memory size
- Binary representation limitations
- Processor speed variations
- Programming language differences
10. Which of the following decimal numbers can be represented exactly in binary floating-point format?
- 0.1
- 0.5
- 0.2
- 0.3