Menu
Recherche




Articles & Documents

Fermer Tutoriaux

Lettre d'information
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
22 Abonnés
CPDB.Net

Nouvelles des Amis
Visites

   visiteurs

   visiteur en ligne

Webmaster - Infos
forum.gifForum - Pépé le compiler - Sujet n°44

Forum - Forum
Pépé le compiler - Pépé le compiler


actif  Sujet n° 44  I was posting in the wrong place

le 31/12/2011 @ 18:02
par lebill2

lebill2



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... smile

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;

end.

Thanks for the patience!

-Bill
  Poster une réponse  Haut
actif sujet actif   clos sujet clos   Important! Important!   Nouveau Nouveau message   -   Rectifier Rectifier message   Clôturer Clôturer sujet   Remonter Remonter
[]
Catégories de discussion  Forum 




^ Haut ^