program PROG15 (input,output); var invalid_operator : boolean; operator : char; number1, number2, result : real;
procedure MULTIPLY;
begin
result := number1 * number2
end;
procedure DIVIDE;
begin
result := number1 / number2
end;
procedure ADD;
begin
result := number1 + number2
end;
procedure SUBTRACT;
begin
result := number1 - number2
end;
procedure GET_INPUT;
begin
writeln('Enter two numbers and an operator in the format');
writeln(' number1 operator number2');
readln(number1); readln(operator); readln(number2)
end;
begin
invalid_operator := FALSE;
GET_INPUT;
case operator of
'*': MULTIPLY;
'/': DIVIDE;
'+': ADD;
'-': SUBTRACT;
otherwise invalid_operator := TRUE
end;
if invalid_operator then
writeln('Invalid operator')
else
writeln(number1:4:2,' ', operator,' ', number2:4:2,' is '
,result:5:2)
end.
{Special changes for Turbo are
case operator of
'*': result := MULTIPLY;
'/': result := DIVIDE;
'+': result := ADD;
'-': result := SUBTRACT;
else invalid_operator := TRUE
end;