Open In App

C Quiz – 106 | Question 3

Like Article
Like
Save
Share
Report

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


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads