Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Floating Point Issues Questions
C programming and IEEE-754 float on little-endian (Intel) The binary equivalent of 5.375 in normalized IEEE-754 single-precision form is: 0100 0000 1010 1100 0000 0000 0000 0000 Given the following C program, what output bytes (one per line, hex, least-significant address first on Intel) will be printed? #include
#include
int main() { float a = 5.375; char p; int i; p = (char)&a; for (i = 0; i <= 3; i++) printf("%02x ", (unsigned char)p[i]); return 0; }
In C language, how will you treat the constant 3.14 explicitly as a long double literal? Add the correct type suffix to the numeric constant so the compiler stores it as long double.
In C language, how will you treat the constant 3.14 explicitly as a float literal? Use the correct single-letter suffix that converts a double literal into a float.
In C and computer architecture contexts, what is the binary representation of the decimal number 5.375? Express the integer and fractional parts correctly in base-2 form.
We want to round off a float variable x to the nearest int value in C. Choose the correct, commonly used expression for positive values of x.
In C, which statement correctly obtains the remainder when dividing the floating values 5.5 by 1.3? Select the standard-library function designed for floating remainders.
Which range corresponds to long double on Turbo C under 16-bit DOS (extended-precision format)? Choose the option that matches the typical 80-bit extended range.
A float occupies 4 bytes. If the hexadecimal values of these 4 bytes are A, B, C, and D, in what order are they stored in memory? Consider hardware endianness when determining byte order.
Which header should be added so that the following program using log(36.0) compiles and links correctly? #include
int main() { printf("%f ", log(36.0)); return 0; }
In standard C, which are the real (floating) data types available? Identify all floating types supported by the language.
What will be the output of the program? #include
int main() { float d=2.25; printf("%e,", d); printf("%f,", d); printf("%g,", d); printf("%lf", d); return 0; }
What will be the output of the program? #include
int main() { float *p; printf("%d ", sizeof(p)); return 0; }
What will be the output of the program? #include
int main() { float a=0.7; if(a < 0.7f) printf("C "); else printf("C++ "); return 0; }
What will be the output of the program? #include
int main() { float a=0.7; if(a < 0.7) printf("C "); else printf("C++ "); return 0; }
What will be the output of the program? #include
#include
int main() { printf("%f ", sqrt(36.0)); return 0; }
What will be the output of the program? #include
#include
int main() { printf("%d, %d, %d ", sizeof(3.14f), sizeof(3.14), sizeof(3.14l)); return 0; }
What will be the output of the program? #include
#include
int main() { float n=1.54; printf("%f, %f ", ceil(n), floor(n)); return 0; }
What will be the output of the program? #include
int main() { float f=43.20; printf("%e, ", f); printf("%f, ", f); printf("%g", f); return 0; }
What will be the output of the program? #include
int main() { float fval=7.29; printf("%d ", (int)fval); return 0; }