making a calculator using records, pointers and links. - 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.

# making a calculator using records, pointers and links.

Posts: 1Member
hey, im trying to work with records and pointers. i have to make a calculator that will calculator any question that i input. the trouble im having is that i dont' know how to find doing the calculation part. i have the equation down, but now im stuck on how to start the calculation. thanks for the help. bye

program pointers6a (input, output);

type
onepoint = ^one;
one = record
numb : integer; {the number in the equation}
oper : char; {the operator in the equation}
next : onepoint; {move to the next node}
end;

const space = ' ';

var
p1, {first numbers for the equation}
p2, {second numbers for the equation}
start, {beginning of the node}
tail {end of node}
: onepoint;
temp : integer;
num {true or false}
: boolean;

procedure printlist (p1 : onepoint);
{*******************************************************************
***********
purpose:to display the original equation on the screen for user to v
iew.
input:the equation in which the user types in.
output:the equation of what the user has typed in.
********************************************************************
**********}
begin
while (p1 <> tail) do
begin
if(p1^.numb > 0) and (p1^.numb < 1000) then
write (p1^.numb);
if(p1^.oper in['+', '-', '*', '/']) then
write(p1^.oper);
p1:=p1^.next;
end;
end; { printlist }

begin {main program}
num := true;
new(start);
start^.numb := temp;
start^.oper:= space;
start^.next:=nil;
tail:= start; {set tail to the beginning}
p1:= start; {set p1 to the beginning}
p2:= start; {set p2 to the beginning}

while (tail^.oper <> '=') do
begin
new(p1);
p1^.next := nil;
if (num) then
begin
p1^.numb:=0;
num:= false;
end
else
begin