previous page main index next page
 

Example 13

Here's another example. It reads in a person's test mark and prints a 'pass' or 'fail' message.

  • type in the program
  • save it as passfail.pas
     
PROGRAM exam;          {pass or fail an exam}

VAR
  name : STRING[20];
  mark : INTEGER;

BEGIN
  WRITE('enter your name ');
  READLN(name);
  WRITE('enter your mark ');
  READLN(mark);
  IF mark > 50
  THEN
    BEGIN
      WRITELN('hi ', name);
      WRITELN('you scored ', mark);
      WRITELN('well done, you passed')
    END
  ELSE
    BEGIN
      WRITELN('sorry ', name);
      WRITELN('you scored ', mark);
      WRITELN('you failed, better luck next time')
    END
END.

  • compile and run the program
  • check it using different data
     
previous page main index next page
 
©2001