I posted about the simple calculator in the wrong area. I'm using the Android compiler, so I should have posted here, correct? (I'm using a rooted Coby Kyros Mid7015 with Android 2.1).
Ok, so I started to write the for - to code that didn't work, and realized this was also my mistake: I forgot to put a line saying:
sum:=0;
So the answer was always different. After inclusion of this line everything worked perfectly!
I'm obviously still learning, and making basic mistakes...
Anyway, here's the code:
My intention is to sum all even numbers from 1 to 100:
program sum_of_evens;
var cont, sum: integer;
begin sum:=0;
for cont:= 1 to 100 do
begin
if cont mod 2 = 0 then
begin
sum:=sum+cont;
end;
end;
writeln('');
writeln('The sum of all even numbers from 1 to 100 is: ',sum);
readln;