all work perfectly just the substraction here's the code:
Program calculation;
uses wincrt;
Procedure menu;
Begin
Writeln('Options:');
Writeln('1. Addition');
Writeln('2. Subtraction');
Writeln('3. Mutiplication');
Writeln('4. Division');
Writeln('5. Exit');
End;
Function GetUserInput(msg:string):integer;
Var
UserInput:integer;
Begin
Write(msg);
Read(UserInput);
GetUserInput:=Userinput;
End;
Procedure Add;
var
add:integer;
Begin
clrscr;
add:=GetUserInput('Enter another number:')+GetUserInput('Enter a number:');
writeln('Result=',add);
End;
Procedure subtract;
var
subtract:integer;
Begin
clrscr;
subtract:=GetUserInput('Enter another number:')-GetUserInput('Enter a number:');
writeln('Result=',subtract);
End;
Procedure SelectOption;
var
option:integer;
Begin
write('Select an option:');
Readln(option);
If ((option<1) or (option>5)) then
writeln('Error wrong input')
Else
If (option=1) Then
Add;
If (option=2) Then
Subtract;
end;
Begin {main}
menu;
SelectOption;
end.
my prob is here:
subtract:=GetUserInput('Enter another number:')-GetUserInput('Enter a number:');
pascal read Enter a number first and then read enter another number, so this id because i put enter another number first and then enter a number.
example
Enter a number: 23
Enter another number:1 (remember this is substraction)
Result = -22 (wrong result, good result is 22)
how to solve it
its very long but i explain my prob so any help plz