Beginner Pascal help - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Beginner Pascal help

Posts: 6Member
I am studying computing at A-level so i have to use Pascal

I am very new to this, this is what i have so far:

[code]PROGRAM Calculator;
USES
CRT, SYSUTILS;
VAR

PROCEDURE Welcome;
BEGIN
WRITELN('Welcome to my calculator that i have programmed in pascal');
WRITELN('First you must choose two numbers to work with');
END;

PROCEDURE Obtain;
BEGIN
WRITE('Enter first number: ');
WRITE('Enter second number: ');
END;

PROCEDURE Obtainoperation;
BEGIN
WRITELN('What do you want to do with these numbers? [Enter *, /, + or -]');
END;

BEGIN

PROCEDURE Divide;
BEGIN
END;

PROCEDURE Multiply;
BEGIN
END;

PROCEDURE Subtract;
BEGIN

PROCEDURE Display;
BEGIN
WRITE('Total is: ');
END;

BEGIN
Welcome;
Obtain;
Obtainoperation;
***not sure what to put here, i want "If Operation is X do Y procedure"
Display;
END.

[/code]

Couple of questions:
1. What do i put where i have the asterisk
2. When i try running as is i get: "Error 26: Type mismatch" at this point:

[code]PROCEDURE Divide;
BEGIN
END;[/code]

• Posts: 59Member
Great start for a beginning program! As for your
what to do at the ***, try a case statement.
[code] case Obtainoperaton of
'*' : Multiply;
'/' : Divide;
'-' : Subtract
end;[/code]
As for error 26, [b]/[/b] is for [italic]real[/italic] number division and
[b]div[/b] is for [italic]integer[/italic] division, which is what you've
You also need an [italic]end;[/italic] for your Subtract
procedure.
• Posts: 6Member
Excellent thanks a lot! I will try that in a minute and give you some more feedback in a bit!

I should have known about the divide being a real number *derp*

Thanks!
• Posts: 6Member
Do i make "case..." a new procedure?

And then run it as

Welcome;
Obtain:
case;
Display;

?

I am not too sure how to integrate this into what i have already, any further direction is greatly appreciated!

thanks
• Posts: 6Member
Never mind i figured it out =]

Thanks!