GK Informatik |
Arbeitsblatt JAVA7b |
JSt. 11/2 |
NAME: |
Zählschleife:
PASCAL | JAVA |
FOR i := 1 TO n DO BEGIN q := i*i; WriteLn(i,'² = ',q) END; |
for (i=1; i<=n; i++) { q = i*i; g.drawString(i+"² = "+q,10,i*20); } |
Schleife mit Anfangsbedingung:
PASCAL | JAVA |
i:=1; WHILE i <= n DO BEGIN q := i*i; WriteLn(i,'² = ',q); INC(i) END; |
i = 1; while (i <= n) { q = i*i; g.drawString(i+"² = "+q,10,i*20); i++; } |
Schleife mit Endbedingung:
PASCAL | JAVA |
i:=1; REPEAT q := i*i; WriteLn(i,'² = ',q); INC(i) UNTIL i > n; |
i = 1; do { q = i*i; g.drawString(i+"² = "+q,10,i*20); i++; } while (i <= n); |
© Ralph-Erich Hildebrandt, Neuss / April 1999