RicardasSim

printf float, double, long double

Sep 4th, 2019
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     float a = 12.345;
  8.     double b = 12345.1234567;
  9.     long double c = 1234567.1234567;
  10.    
  11.     printf("%f\n%f\n%Lf\n\n", a, b, c);
  12.  
  13.     printf("%.7f\n%.7Lf\n", b, c);
  14.  
  15.     return 0;
  16. }
  17.  
  18. /*
  19. output:
  20.  
  21. 12.345000
  22. 12345.123457
  23. 1234567.123457
  24.  
  25. 12345.1234567
  26. 1234567.1234567
  27.  
  28. */
Advertisement
Add Comment
Please, Sign In to add comment