School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,145 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,738 people online right now. Registration is fast and FREE... Join Now!




Help with PASCAL and Sums

 

Help with PASCAL and Sums

korefuji

16 Jun, 2009 - 04:01 PM
Post #1

New D.I.C Head
*

Joined: 27 Mar, 2009
Posts: 6

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

User is offlineProfile CardPM
+Quote Post


masteryee

RE: Help With PASCAL And Sums

16 Jun, 2009 - 11:54 PM
Post #2

D.I.C Regular
***

Joined: 16 May, 2009
Posts: 269



Thanked: 38 times
My Contributions
I never worked with pure Pascal (I'm a Delphi developer), but you may be able to try something like this:

Delphi

a := 9;
b := a + 4;
writeln ('The sum of a + b = ' + FloatToStr(a + b ));

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:48PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month