Range Check

Numbers or codes are checked to ensure that they are in the permitted range. In the following program, a student’s age must be in the range 11-19 (inclusive) to be accepted.

program RangeCheck;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  Age : integer;
begin
  repeat
    write('Please enter the age of the student. ');
    readln(Age);
  until (Age > 10) and (Age < 20);
    writeln('Age ', Age, ' has passed the range check.');
    readln;
end.

Programming - a skill for life!

Checking data to see if it is sensible