C- Floating Point Issues MCQ
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<stdio.h>
int main()
{
printf("%f\n", log(36.0));
return 0;
}
- #include
- #include
- #include
- #include
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