Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "math.h"
  3.  
  4. double f(double x, double y) {
  5.     return y*y + 1;
  6. }
  7.  
  8. int main() {
  9.     // input data
  10.     double y0 = 0.0, x0 = y0, f0 = f(x0, y0);
  11.  
  12.     // iteration data
  13.     double x = x0, y = y0, h = 0.05;
  14.     int i, a=0, b=1, n = (b-a)/h;
  15.  
  16.     // main loop
  17.     for (i=0; i <= n + 1; ++i) {
  18.         printf("y(%.03f) = %.05f\n", x, y);
  19.         y = y + h*f(x, y);
  20.         x += h;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement