K = 1; 
s = 20; 
y0 = 100; 
npoints = 50; 
dt = 0.1; 

y = zeros(npoints,1); 
t = zeros(npoints,1); 

y(1) = y0; 
t(1) = 0.0; 

for step=1:npoints-1 
y(step+1) = y(step) + dt*K*(y(step)-s); 
t(step+1) = t(step) + dt; 

if ((y(step) < 1000) & (y(step+1) > 1000)) % conditional statement 
fprintf('y crosses 1000 at t= %14.7f',t(step+1)); % output result to the screen 
end 

end 
