Off[General::spell1];
Clear[Euler,f0,a,b,x0,n];
Euler[f0_,a_,b_,x0_,n_] :=
Module[{f,h,k,T, X },
  Set@@{f[t_,x_],f0};
  h = (b - a)/ n //N ;
  T = Table[0,{n+1}];
  X = Table[0,{n+1}];
  T[[1]] =  a //N;
  X[[1]] = x0 //N;
  For[k=1, k<=n, k++,
    X[[k+1]] = X[[k]] +
        h f[T[[k]],X[[k]]] //N;
    T[[k+1]] = a + h k //N];
  Return[ Transpose[{T,X}] ] ];
On[General::spell1];

Clear[f,t,x];   
f[t_,x_] = Cos[t] - Sin[x] +t^2;

Euler[f[t,x],-1,1,3,10]

Clear[pts];
pts = Euler[f[t,x],-1,1,3,10];
dots= ListPlot[pts,PlotStyle->
{PointSize[0.015]}, DisplayFunction->  Identity];
lines= ListPlot[pts,PlotJoined->True, AspectRatio -> 0.5 , DisplayFunction->  Identity ]; 
Show[ lines, dots, DisplayFunction->
$DisplayFunction]

Clear[pts];
pts = Euler[f[t,x],-1,1,3,200];
ListPlot[pts,PlotJoined->True, AspectRatio -> 0.5];

Clear[ss];
ss=NDSolve[{x'[t]==f[t,x[t]],
      x[-1]==3},x[t],{t,-1,1}];
Plot[Evaluate[x[t]/.ss],
  {t,-1,1},AspectRatio -> 0.5];

Clear[xx];
xx[t_]= x[t] /. First[ss];
Error = Table[pts[[i,2]]-
   xx[-1+ (i-1) /100], {i,1,10}]

Clear[f,t,x];
f[t_,x_] = (t *x - x^2) / t^2;

Clear[pts];
pts = Euler[f[t,x],1,3,2,200 ];
ListPlot[pts,PlotJoined->True, AspectRatio -> 1];

Clear[ss,xx];
ss=DSolve[{x'[t]==f[t,x[t]],x[1]==2},
  x[t],t];
xx[t_]= x[t] /. First[ss]

Plot[xx[t],{t, 1,3},AspectRatio -> 1]

Error1 = Table[pts[[i,2]]-
   xx[1+ (i-1) /100], {i,1,10}]//N

Error2=Table[pts[[i,2]]-
   xx[1+ (i-1) /100], {i,90,100}]//N