Modified Euler’s Method
#include<stdio.h> #include<conio.h> #define F(x) x+y int main (void) { float a,c,b,h,x,f,i,y,y1,y11=0.01,m,n,f2; clrscr(); printf("Enter the value of a & c as y(a)=c: "); scanf("%f %f",&a,&c); printf("Enter the value of b as y(b)=?"); scanf("%f",&b); printf("Enter the value of h: "); scanf("%f",&h); x=a; y=c; for(i=a;i<b;i=i+h) { f= F(x); y1=c+ h*f; x=x+h; y=y1; m=0.0001;n=0.0 ; while(m>=n) { m=y; //primarry f2=F(x); y11=c+h*(f+f2)/2; y=y11; m=y11; f2=F(x); //secondary y11=c+h*(f+f2)/2; y=y11; n=y11; } c=y11; y=y11; } printf("\nRequired ans: %f",c); getch(); return 0; }