program forloopC; { This program demonstrates another "for" loop. It uses the loop to print out the numbers from m to n, where m and n are entered by the user. } var m, n : integer; { start at m, end at n } i : integer; { looping variable } begin write('Start at: '); readln(m); write('End at: '); readln(n); for i := m to n do writeln(i); end.
Below we show a compilation and run of the program.
% pc forloopC.p % a.out Start at: 5 End at: 14 5 6 7 8 9 10 11 12 13 14