-1

I need the program to print "0.03571428". Instead my program prints only 0.035714. Sorry for the stupid question but I am a beginner as you can see!

int main(int argc, char *argv[]) {
        long double a;
        int b = 1, c = 28;
         a = (long double) b / (long double) c;    
        printf("%Lf", a);
        return 0;

}

1 Answers1

3

The %f format specifier prints 6 digits after the decimal point by default. To change that, add a precision modifier specifying the number of digits:

printf("%.8Lf", a);
dbush
  • 205,898
  • 23
  • 218
  • 273