C Programming
FLOATING POINT ISSUES MCQs
Total Questions : 28
Page 1 of 3 pagesprintf("%e,", d); Here '%e' specifies the "Scientific Notation" format.
So, it prints the 2.25 as 2.250000e+000.
printf("%f,", d); Here '%f' specifies the "Decimal Floating Point" format.
So, it prints the 2.25 as 2.250000.
printf("%g,", d); Here '%g' "Use the shorter of %e or %f". So, it prints the
2.25 as 2.25.
printf("%lf,", d); Here '%lf' specifies the "Long Double" format. So, it prints
the 2.25 as 2.250000.
ceil(x) round up the given value. It finds the smallest integer not < x.
floor(x) round down the given value. It finds the smallest integer not > x.
printf("%f, %f`setminus`n", ceil(n), floor(n)); In this line ceil(1.54) round up the 1.54 to 2
and floor(1.54) round down the 1.54 to 1.
In the printf("%f, %f`setminus`n", ceil(n), floor(n)); statement, the format specifier "%f %f"
tells output to be float value. Hence it prints 2.000000 and 1.000000.
if(a < 0.7f) here a is a float variable and 0.7f is a float constant. The float variable a is not less than 0.7f float constant. But both are equal. Hence the if condition is failed and it goes to else it prints 'C++' Example:
#include<stdio.h> int main() { float a=0.7; printf("%.10f %.10fn",0.7f, a); return 0; }Output: 0.6999999881 0.6999999881
printf("%e, ", f); Here '%e' specifies the "Scientific Notation" format. So,
it prints the 43.20 as 4.320000e+01.
printf("%f, ", f); Here '%f' specifies the "Decimal Floating Point" format. So,
it prints the 43.20 as 43.200001.
printf("%g, ", f); Here '%g' "Use the shorter of %e or %f". So, it prints the 43.
20 as 43.2.
sizeof(3.14f) here '3.14f' specifies the float data type. Hence size of float is 4 bytes.
sizeof(3.14) here '3.14' specifies the double data type. Hence size of float is 8 bytes.
sizeof(3.14l) here '3.14l' specifies the long double data type. Hence size of float is 10 bytes.
printf("%f`setminus`n", sqrt(36.0)); It prints the square root of 36 in the float format
(i.e 6.000000).
Declaration Syntax: double sqrt(double x) calculates and return the positive
square root of the given number.
sizeof(x) returns the size of x in bytes.
float *p is a pointer to a float.
In 16 bit compiler, the pointer size is always 2 bytes.
In 32 bit compiler, the pointer size is always 4 bytes.
printf("%d`setminus`n", (int)fval); It prints '7'. because, we typecast the (int)fval in to integer.
It converts the float value to the nearest integer value.
if(a < 0.7) here a is a float variable and 0.7 is a double constant. The float variable a is less than double constant 0.7. Hence the if condition is satisfied and it prints 'C'
#include<stdio.h> int main() { float a=0.7; printf("%.10f %.10f\n",0.7, a); return 0; }Output: 0.7000000000 0.6999999881
fmod(x,y) - Calculates x modulo y, the remainder of x/y. This function is the same as the modulus operator. But fmod() performs floating point divisions. Example:
#include<stdio.h> #include <math.h> int main () { printf ("fmod of 5.5 by 1.3 is %lf\n", fmod (5.5, 1.3) ); return 0; }Output: fmod of 5.5 by 1.3 is 0.300000
Recent Questions
Q. The Value Engineering Technique In Which Experts Of The Same....
Q. If Transcription Should Not Be Carried Out Beyond The Insert....
Q. Buffalo Is To Leather As Llama Is To....?
Q. Choose The Correct Answer From The Given Options To Fill The....
Q. The Arithmetic Mean (average) Of The First 10 Whole Numbers ....
Q. Which Governor General Is Remembered For The Annulment Of Th....
Q. When The Voltage Across A Capacitor Is Tripled, The Stored C....
Q. My Mother Bakes Cakes.
Q. Log Mean Temperature Difference In Case Of Counter Flow Comp....
Q. Which Of The Following Is Not A Matter Of Local Government?
Q. Which Drugs Can Easily Pass The Placental Barrier?
Q. Which Of The Following Is Not A Benefit Of BLAST?
Q. A Part Of John's Salary Was Cut By The Government. What....
Q. The Swollen Part Of The Pistil Is Known As ________ .
Q. By Definition, Make A Map Is To Select Certain Features As R....
Q. Which Of The Following Is The Best Tube Material From Therma....
Q. If You Are Going To Use A Combination Of Three Or More AND A....
Q. (a) A Ball Is Dropped From A Height Of 30m. After Striking T....
Q. What Is The Approx. Value Of W, If W=(1.5)11, Given Log2 = 0....
Q. In The Following Questions, The Symbols $, ©, *, @ And # Ar....