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

MiddleMiddle 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
Number1, Number2, Operation, Answer :LONGINT;

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: ');
READLN(Number1);
WRITE('Enter second number: ');
READlN(Number2);
END;

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

PROCEDURE Add;
BEGIN
Answer:=Number1 + Number2;
END; Addition

PROCEDURE Divide;
BEGIN
Answer:=Number1 / Number2;
END;

PROCEDURE Multiply;
BEGIN
Answer:=Number1 * Number2;
END;

PROCEDURE Subtract;
BEGIN
Answer:=Number1 - Number2;

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

BEGIN
Welcome;
Obtain;
Obtainoperation;
***not sure what to put here, i want "If Operation is X do Y procedure"
Display;
READLN;
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
Answer:=Number1 / Number2; *here
END;[/code]

Comments

Sign In or Register to comment.