How to print long double in c

We can print the long double value using %Lf format specifier.




%Lf format specifier for long double

%lf and %Lf plays different role in printf.

So, we should use %Lf format specifier for printing a long double value.


#include<stdio.h>

int main()
{
    long double d = 3.14e+2;

    printf("Value of long double d = %Lf\n",d);

    return 0;
}

Output

Value of long double d = 314.000000