Loops

There are three different kinds of loops: while, for, and do-while loops.

The uses of these loops are almost alike. But, there are some cases that they're different. It only depends on how you use it.

FOR LOOP

  • repeats for a specified number of times
Syntax:
for(initialization; comparison ;increment or decrement)
{statements;}

WHILE LOOP
  • a loop that repeats until a certain condition is satisfied
Syntax:
while(condition)
{statements;)


DO-WHILE LOOP
  • unlike the while loop, the do-while loop tests the condition at the end of the loop
Syntax:
do
{statements;}
while(condition);

No comments:

Post a Comment

Extended Search

Custom Search
Hello World