fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double func(double x) {
  5. return sin(x);
  6. }
  7.  
  8. int main(void)
  9. {
  10. double limit = 1.5;
  11. double step = 0.5;
  12. double middle = 0.0;
  13.  
  14. for (double t = 0.0; t <= limit; t += step) {
  15. double x1 = middle - t;
  16. double x2 = middle + t;
  17. fprintf(stdout,"| x = %lf | y = %lf | x = %lf | y = %lf |\n",
  18. x1, func(x1), x2, func(x2));
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
| x = 0.000000 | y = 0.000000 | x = 0.000000 | y = 0.000000 |
| x = -0.500000 | y = -0.479426 | x = 0.500000 | y = 0.479426 |
| x = -1.000000 | y = -0.841471 | x = 1.000000 | y = 0.841471 |
| x = -1.500000 | y = -0.997495 | x = 1.500000 | y = 0.997495 |