The following symbols represent the arithmetic operators, ie, use them when you wish to perform calculations.
+ AdditionAddition Example
- Subtraction
* Multiplication
/ Division
Subtraction Example
program Add (output);
var number1, number2, result : integer;
begin
number1 := 10;
number2 := 20;
result := number1 + number2;
writeln(number1, " plus ", number2, " is ", result )
end.
Multiplication Example
program Subtract (output);
var number1, number2, result : integer;
begin
number1 := 15;
number2 := 2;
result := number1 - number2;
writeln(number1, " minus ", number2, " is ", result )
end.
Division Example
program Multiply (output);
var number1, number2, result : integer;
begin
number1 := 10;
number2 := 20;
result := number1 * number2;
writeln(number1, " multiplied by ", number2, " is ", result )
end.
program Divide (output);
var number1, number2, result : integer;
begin
number1 := 20;
number2 := 10;
result := number1 / number2;
writeln(number1, " divided by ", number2, " is ", result )
end.
SELF TEST
The following program contains a few errors. Identify each error (there are seven), and show the correct version on the right.
progam TEST (output) _______________________________
var number1, number2; integer; _______________________________begin; _______________________________
number1 = 24; _______________________________
number2 := number1 * 4; _______________________________
writeln('Help ) _______________________________
end
Answers
The following program contains a few errors. Identify each error (there are seven), and show the correct version on the right.
progam TEST (output)
var number1, number2; integer;
begin;
number1 = 24;
number2 := number1 * 4;
writeln('Help )
endprogram TEST (output);
var number1, number2 : integer;
begin
number1 := 24;
number2 := number1 * 4;
writeln('Help' )
end.