Fandom

Borland Pascal Wiki

IF...THEN...ELSE

35pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.


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.

Also on Fandom

Random Wiki