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 do..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 that we use 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 we use it 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. We use it 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.
We can not use break statement outside of loop or switch case.
break statement can be used with a loop(while, do-while, for) statements & switch-case statement
We use continue statement 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;
We use break and continue statements along with while, do-while, for statements.
while using the break and continue statements programmer need to understand first the implementation of this statements.