While Loops
The while loop is used to repeat a block of code until a given condition is true.
For example, let's print "Hello" 5 times:
Output:
Hello
Hello
Hello
Hello
Hello
==============================
As you can see, each time the loop starts, the value of i is incremented by one. The loop runs until i is greater than 5.
We can use a while loop to calculate the sum of numbers from 1 to 100:
Коментарі