Can anyone explain how to take the following sums and program it so that the results is the sum and the result of the sum printed on the screen. So for
writeln('a:=+9'); it will display as "The sum of a:=+9 is [answer]". I know how to do the printing part, but for some reason my sums aren't being calculated. Should it be:
writeln('The sum of a:=+9 is', [the calcualted sum] ); this line doesn't seem to compile correctly. And if I want to do the next line writeln('The sum of b:=a+4 is', [calculated sum]) i don't remember how to do it. If that makes sense.
CODE
program Integer_Math_DEMO;
VAR a,b,c,d:integer;
e:real;
begin
writeln ('a:=+9');
writeln ('b:=a+4');
writeln ('c:=a+b');
writeln ('d:=4*a*b');
writeln ('e:=a/b');
readln;
end.
and the same with this one:
CODE
program Real_Math_DEMO;
VAR a,b,c,d:real;
begin
writeln ('a:=3.234');
writeln ('b:=a+1.101');
writeln ('c:=a+b');
writeln ('d:=4.234*a*b');
writeln ('d:=2.3/b');
writeln ('d:=a-b');
writeln ('d:=(a+b)/(12.56-b)');
readln;
end
I know it's something simple, as I have completed this before, but looking back at it now I don't remember how I did it. And the print out of the correct results is in a folder locked away without access until the end of term.
thanks in advance