Que diferencia tiene El Bucle while con if, si evalúan lo mismo ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Que diferencia tiene El Bucle while con if, si evalúan lo mismo ?

9th Sep 2017, 5:30 PM
Gabriel Ivan Ortiz Enriquez
2 Answers
+ 3
To add to what @P R explained, while(<condition>) is used to repeat the execution of the code following the "while" as long as <condition> evaluates to true. if(<condition>) is used in branching, or making decision, the block of code following the "if" will be executed only when <condition> evaluates to true. If there's an "else" part combined with "if" the block of code following "else" will be executed if <condition> specified in "if" evaluates to false. Hope this helps, although, the question was not in English.
9th Sep 2017, 5:55 PM
Ipang
+ 4
Translation : What difference does the while loop have with if, if they evaluate the same? While is a looping statement (block of statement inside will be executed repeatedly till the condition is true) and if is a conditional statement( block of statement inside will be executed if condition is true)
9th Sep 2017, 5:36 PM
P R
P R - avatar