I just don't understand the logic behind "While loop" syntax


#1


I understood the logic behind "For loop" syntax. I had no problem writing it from scratch. But, with "While loop", I just don't understand it. Even though it seems more flexible than "For loops", but I just go through the instructions without understanding what I am doing. When we have to write it from scratch, I have to go back to prior exercises many times, before I finish the syntaxes.
Since this is a general question I have no links or codes to post.


Replace this line with your code.


#2

while loop is simpler then for loop? general syntax:

while (condition){
    /* execute this code */
}

while the condition is true, execute the code in the loop

You can always check external documentation:

if you need a slightly different explanation


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.