Remove["Global`*"]
yAx=DSolve[{y'[x]==y[x]*Cos[x],y[0]==1},y[x],x];
f[x_,y_]:=y*Cos[x];
g[x_,y_]:={x+h,y+h*f[x,y]};
yEt = {}; Do[h=20.0/n;
AppendTo[yEt, NestList[g@@#&,{0,1},n]],{n,{50,100,200,400}}];
Show[ListLinePlot[yEt,PlotStyle->Dotted],
Plot[y[x]/.yAx,{x,0,20}]]

Remove["Global`*"]
yAx=NDSolve[{y'[x]==Sin[x*y[x]],y[0]==6},y[x],{x,0,35}];
f[x_,y_]:=Sin[x*y];
g[x_,y_]:={x+h,y+h*f[x,y]};
h=0.2;
n=100;
yEt = NestList[g@@#&,{0,6},n];
Plot[y[x]/.yAx,{x,0,35},Epilog->{PointSize[0.0025],Red,Line[yEt],Point[yEt]}]

Remove["Global`*"]
yAx=DSolve[{y'[x]==y[x]*Cos[x],y[0]==1},y[x],x];
f[x_,y_]:=y*Cos[x];
g[x_,y_]:={x+h,y+h*f[x+h/2,y+h/2 f[x,y]]};
yEt = {}; Do[h=20.0/n;
AppendTo[yEt, NestList[g@@#&,{0,1},n]],{n,{50,100,200,400}}];
Show[Plot[y[x]/.yAx,{x,0,20}],
ListLinePlot[yEt,PlotStyle->{Dotted,Red}]]