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.
Observe the formatted-output behavior in C for a float value. Given:\n#include
\nint main()\n{\n float d = 2.25;\n printf("%e,", d);\n printf("%f,", d);\n printf("%g,", d);\n printf("%lf", d);\n return 0;\n}\nWhat is the exact output (spacing and commas as shown)?
Pointer size question across platforms: Given\n#include
\nint main()\n{\n float p;\n printf("%d\n", sizeof(p));\n return 0;\n}\nWhat is sizeof(float) typically on 16-bit versus 32-bit compilers?
Floating literal precision comparison in C: given\n#include
\nint main()\n{\n float a = 0.7;\n if(a < 0.7f)\n printf("C\n");\n else\n printf("C++\n");\n return 0;\n}\nWhat will be printed (consider default promotions and literal types)?
In C programming, consider floating-point comparison:\n\n#include
\nint main()\n{\n float a = 0.7;\n if (a < 0.7)\n printf("C\n");\n else\n printf("C++\n");\n return 0;\n}\n\nWhat will be printed, given typical binary floating-point representation and usual type promotions during comparison?
In C with math.h included, what does this program print?\n\n#include
\n#include
\nint main()\n{\n printf("%f\n", sqrt(36.0));\n return 0;\n}\n\nAssume typical IEEE-754 and default printf formatting for %f.
On a typical platform where sizeof(float)=4, sizeof(double)=8, and sizeof(long double)=12, what does this program print?\n\n#include
\n#include
\nint main()\n{\n printf("%d, %d, %d\n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l));\n return 0;\n}\n\nAssume long double uses extended precision storage occupying 12 bytes.
With math.h functions, what is the output of this code?\n\n#include
\n#include
\nint main()\n{\n float n = 1.54;\n printf("%f, %f\n", ceil(n), floor(n));\n return 0;\n}\n\nAssume default %f precision.
Given a float f = 43.20, what do these printf conversions produce?\n\n#include
\nint main()\n{\n float f = 43.20;\n printf("%e, ", f);\n printf("%f, ", f);\n printf("%g", f);\n return 0;\n}\n\nAssume typical IEEE-754 and default precisions for %e, %f, and %g.
What is printed after casting a float to int in C?\n\n#include
\nint main()\n{\n float fval = 7.29;\n printf("%d\n", (int)fval);\n return 0;\n}\n\nAssume standard C semantics for casts and printf.