Skip to content
Related Articles

Related Articles

Improve Article
C Quiz – 106 | Question 3
  • Last Updated : 12 Oct, 2015

In a C program, following variables are defined:

float      x = 2.17;
double   y = 2.17;
long double z = 2.17;

Which of the following is correct way for printing these variables via printf.
(A) printf(“%f %lf %Lf”,x,y,z);
(B) printf(“%f %f %f”,x,y,z);
(C) printf(“%f %ff %fff”,x,y,z);
(D) printf(“%f %lf %llf”,x,y,z);

Answer: (A)

Explanation: In C language, float, double and long double are called real data types. For “float”, “double” and “long double”, the right format specifiers are %f, %lf and %Lf from the above options. It should be noted that C standard has specified other format specifiers as well for real types which are %g, %e etc.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :