🚀 Learn 90+ coding courses & crack 200+ competitive exams — powered by learning intelligence on Leyaa.ai →

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

🚀 Code smarter. Crack exams faster.

90+ interactive coding courses & 200+ competitive exam prep — powered by learning intelligence. All free.

Try Leyaa.ai Now →