r1=y'[t]==Cos[t];
podm1=y[0]==0;

res=DSolve[{r1,podm1},y,t]

Plot[y[t]/.res,{t,0,2π}]
Plot[y[t]/.res,{t,-2π,4π}]

nres=NDSolve[{r1,podm1},y,{t,0,2π}]

Plot[y[t]/.nres[[1]],{t,0,2π}]

y[3π]/.nres[[1]]

Plot[y[t]/.nres,{t,-2π,4π}]