fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void prec_print(double d, int prec)
  5. {
  6. printf("%.*f\n", prec, d);
  7. }
  8.  
  9. int main(void)
  10. {
  11. const double x = acos(0.0) * 2;
  12. for (int i = 0; i <= 10; ++i) prec_print(x, i);
  13. }
  14.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
3
3.1
3.14
3.142
3.1416
3.14159
3.141593
3.1415927
3.14159265
3.141592654
3.1415926536