Loops offer a quick and easy way to do something repeatedly and
for loop and
if else statement are one of the other control structure.
Control Structures are just a way to specify flow of control in programs.
Any algorithm or program can be more clear and understood if they use
self-contained modules called as logic or control structures.
It basically analyzes and chooses in which direction a program flows
based on certain parameters or conditions.
Now let's learn about two important statements:
continue: is to exit the current iteration of the loop,
and continue to the next one.
Let's say we want to only log strings to the console.
break : is used to completely terminate the whole loop.
Let's say I want to stop logging, after I find the first number
Whenever you do need a loop without a counter variable
You can reach out to for the
Basically that happens, when you do NOT know beforehand how many
iteration the loop will have, in your program.
while loop what really needs, is the condition.
In this example it's
while(rep <= 10)