orneto

euller

Jun 24th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. double funcao(double x, double y){
  6.  
  7.     return (y);
  8. }
  9.  
  10. int main()
  11. {
  12.     double x0, y0, x, h, ant, antresul, resul = 0;
  13.  
  14.     printf("Digite o valor de x e seu valor de y (Exemplo: f(2) = 3/ x= 2, y=3): ");
  15.     scanf(" %lf %lf",&x0,&y0);
  16.     printf("Digite o valor de x que deseja encontrar o y(x): ");
  17.     scanf(" %lf",&x);
  18.     printf("Digite o tamanho de cada intervalo: ");
  19.     scanf(" %lf",&h);
  20.     printf("\n\n");
  21.  
  22.     while((float)x0 < (float)x){
  23.  
  24.         //resul = antresul + antresul * h + funcao() * pow(h,2)/2;
  25.         resul = y0 + h * funcao(x0,y0);
  26.         printf("y[%lf] = %lf\n",x0+h,resul);
  27.  
  28.         y0 = resul;
  29.         x0 += h;
  30.  
  31.     }
  32.  
  33.     printf("\n\nResultado: %.8lf \n",resul);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment