Menu
Search




Articles & Documents

Close Tutorials

Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
22 Subscribers
CPDB.Net

Friends News
Visits

   visitors

   visitors online

Webmaster - Infos
forum.gifForum - ppCompiler - Topic #42

Forum - Forum
ppCompiler - ppCompiler


active  Topic # 42  Problem With Simple Calculator

30/12/2011 @ 19:09
by lebill

lebill



Hi!

I had a problem with a simple calculator algorithm, it didn't come up with the right result (this same structure works on Delphi 7). Here is the code:

program sum;

var n1, n2, result: integer;

begin

writeln('');
write('Type in the first number: ');
readln(n1);
writeln('');
write('Type in the second number: ');
readln(n2);

result:= n1 + n2;

writeln('The result is: ',result);
readln;

end.

Any feedback would be appreciated, I really enjoy using your program!

-Bill
  Post an answer  Top
Answer n° 1
--------
31/12/2011 @ 05:04
by lebill2

lebill2

visitor
Oops, sorry, I checked the code again: instead of the first variable n1 I put result... Of course it didn't work!

Even so, I had some trouble with another algorythm using the "for to", I'll review it to see if the problem is also my typing on this one...

Thanks anyway!

-Bill
Write to lebill2   Post an answer  Top
Answer n° 2
--------
31/12/2011 @ 11:01
by Philippe

Anonymous

visitor
Anyway, thanks to your post,I found that the the readln procedure does not work properly on some devices, depending on the keyboard.
Write to Philippe   Post an answer  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 




^ Top ^