+ 1
Will while function do function below it if its true?
for example, i have while (blabalbala){} and the value is true and being executed but i also have for(blablabla){} below it, will it be executed or remain as unused line?
1 Antwort
+ 8
for loops have different syntax.
for (initialization; condition; increment) { //code }
e.g.
for (int i = 0; i < 5; i++) { //code }
If you want to just include a boolean variable in a for loop condition, do:
for (; isTrue; ) { //code }
*** ***
Hence, if you put two loops in such:
while (isTrue) { // code }
for (; isTrue; ) { // code }
Both loops will be executed. (As long as they don't run indefinitely)