Please enable JavaScript.
Coggle requires JavaScript to display documents.
LOOPING STATEMENT - Coggle Diagram
LOOPING STATEMENT
- Looping is a sequence of instructions that is continually repeated until a certain condition is reached
- A loop is away of repeating a statement a number of times until some way of ending the loop occurs.
-
-
-
-
For statement declaration as shown above can be divided into 3 parts ;
1) Initialization statement >> In this we initialize the loop control value to a starting value. Eg. X=0 ;
2) Test expression >> In this evaluate the condition for the iteration of the loop and loop repeat only when this is true, Eg. X<10
3) Update statement >> In this determine how the value of loop control value changes with each iteration of the loop. It can be increment, decrement or any mathematical expression. Eg. X++
- Statement in above for can be a single statement, block statement or at blank statement.
- also note that each part is seperated by a semi colon.
-
-
- The while statement is used to carry out looping operations, in which a group of statement is executed repeatedly, until some condition
-
How the BREAK loop works
- In C programming, break is used in terminating the loop immediately after it is encountered
- The break statement can be used in terminating all three loops FOR ,WHILE and DO WHILE
- When the BREAK statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop
- It can be used to terminate a case in the SWITCH statement.
- If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the execution of the innermost loop and start executing the next line of code after the block
-
-
-