# Pascal Arithmetic Program Using IF THEN statement

Pascal program using control statements. Each section performs a different basic mathematical arithmetic.

YOU MIGHT ALSO LIKE: Pascal Program To Create And Save Records In A Textfile
```Program Basic_Arithmetic;
Uses crt;
Label 20;
Var  A, B, Sum, Subtract, Divide, Multiply, Average:  Real;
Choice : Integer;
YN : Char;

Begin
20 : Clrscr;
Writeln (' For addition, press 1');
Writeln (' For subtraction, press 2');
Writeln (' For Divison, press 3');
Writeln (' For multiplication, press 4');
Writeln ('To calculate Average, press 5');
Writeln ('To exit, Press 6');
Writeln ('Enter a number of your choice');

If choice = '1' then
Begin
Writeln (' Enter your first number');
Sum := A + B;
Writeln (' The answer is', Sum);
Goto 20;
End;

If choice = '2' then
Subtract := A - B ;
Goto 20;
End;

If choice = '3' then
Divide := A / B;
Goto 20;
End;

If choice = '4' then
Multiply := A * B
Goto 20;
End;

If choice = '5' then
Sum := A + B;
Average := Sum / 2 ;
Goto 20;
End;

If choice = '6' then
Writeln (' You are about exiting this program, to continue press Y/N');
If YN = 'Y' then
Writeln (' Goodbye');
Halt;
If YN = 'N' then
goto 20;
end;
End.
```

If you have more numbers you can use a looping statement which will save time instead of the If then statement.

URL Of Post: