for loop - Java alternative code in Pascal -
for loop - Java alternative code in Pascal -
just simple question dealing recently.. alternative of code in pascal? possible accomplish similar syntax?
for (i=1; i<11; i++) { j= x*10; x= x+1; }
the issue is, in loop assigning desired range operation (increment i) on same line.
with pascal able do
for i:=1 10
but then, 1 time within loop unable command variable involved in loop status (i). , produces different outcome.
the for statements in java , pascal different. in java, in "curly brace languages" derived c, statement while loop in disguise: for (x; y; z) { p; }
same thing x; while (y) { p; z; }
(well, not same thing, there difference in scope of variables used). in pascal, for statement iterates on number of values known beforehand, much java's for each statement (for (int : intarray) { ... }
).
theoretically, there big difference in while loops , for loops: in while loop not case loop status ever false, loop forever. for loop know number of iterations beforehand. makes for loop less powerful while loop, guaranteed for loop terminate. in practical programming languages, distinction between 2 bit blurred, of import know c/java for loop closer theoretical while loop, while pascal for behaves more theoretical for loop. (this reason in many, not all, pascal dialects cannot modify loop variable within for loop.)
so, indeed, illustration not work pascal for loop, of course of study can utilize pascal while loop accomplish same effect.
java for-loop pascal
Comments
Post a Comment