Borland Pascal Wiki
Register
Advertisement


Program Marks

uses crt

var a,b, average: real;

Begin

clrscr

  writeln('Your two marks are:');

  readln(a,b);

    average= (a +b)/2;

   writeln('Your average is:'); 

if     average >=50

   write('You Passed! Good Job!')
else
    write ('You failed, sorry');

readln

End.
The conditional instruction is for acting intelligently, taking one or more actions if a condition is met and other action(s) if another condition is met. For example:

IF b=0 THEN
 write ('You can not do divisions by 0!')
ELSE
 BEGIN
 write (a div b);
 readln;
 END;
end.

So, the syntax is:

if <condition> then <command> else <command>

If there are more commands to execute, they will be grouped in BEGIN ... END. If after IF's command (or the END if there are more commands) there is the ELSE statament, then there must be no semicolon after the previous word.

Advertisement