Bodhak c looping statements tutorial now we are going to learn with syntax’s and examples about Iterative Statements(Loops), Working with while loop, Working with for loop, Working with doing..while.
LOOPING CONTROL STATEMENTS: Looping Control statements execute the selected group of the statement(s) repeatedly. The selected group of statements executed repeatedly depends on the given expression.
c looping statements tutorial:-
while is a control statement used to execute a set of statements repeatedly depending upon the outcome of a test.
the statements are executed until the expression becomes zero(false)
for is a control statement and is used to create a loop of iterative operations.
The statement is executed until the expression expression2 becomes zero(false).
The expression exp1 is evaluated only once in the beginning and expression3 is evaluated at the end of every iteration.
do while Statement:
do is a control statement that creates a loop of operations. It is used with another keyword while
The loop is terminated when expression becomes zero(false);
The do while is executed at least once irrespective of the expression is true or false
the break is a statement that terminates an innermost loop or switch.
It can not be used outside of loop or switch case.
break statement can be used with a loop(while, do-while, for) statements & switch-case statement
The continue statement is used to bypass the remainder of the current pass through a loop. The loop does not terminate when a continue statement is encountered. Rather, the remaining loop statements are skipped and the computation proceeds directly to the next pass through the loop.
continue; st 3;
The break and continue statements are used along with while, do-while, for statements.
while using the break and continue statements programmer need to understand first the implementation of this statements.