Sometimes, we may need to execute the same piece of code many times. Generally,program statements are executed sequentially: the first statement in a function occurs first, followed by the second statement, and so on.
Programming languages provide multiple control structures for more complex execution paths.
Loop statements allow us to execute a statement or group of statements multipletimes, and the following is a flowchart of loop statements in most programming languages:
The C language provides the following loop types. Click on the link to view each type for details.
cyclical patterns |
description |
while recurrence |
Repeat statements or group of statements when a given condition is true. It tests the condition before executing the loop host. |
for recurrence |
Performing a sequence of statements multiple times, simplifying the code that manages loop variables. |
do…while recurrence |
similar to the while statement except that it test condition at the end of the loop subject. |
nest loop |
Use one or more loops in the loop of while, for or do… while |
The loop-control statement changes the order that code is executed. With it you can jump in the code.
C language provide the following loop control statements. Click on the link to see the details of each statement.
control statement |
description |
break sentence |
To terminate the loop or switch statement, the program stream continues to execute the next statement which following the loop or switch. |
continue Statement |
Tell loop body to stop the cycle immediately and start the next cycle again. |
goto sentence |
Transfer the control to the tagged statement. But do not recommend using the goto statement in a program. |
If the conditions are never false, then the loop becomes an infinite loop. The for cycle can be used to realize infinite cycles in the traditional sense . Since any of the three expressions that constitute a loop is not a must, you can leave some conditional expressions blank to form an infinite loop.
A conditional expression is assumed to be true when it does not exist. You can also set an initial value and an incremental expression, but in general, the C programmer tends to use the for (;;) structure to represent an infinite loop.
A above C cycle is belong to Shenzhen HDV Photoelectron Technology co., LTD., a software technical operation., And the company has brought together a powerful software team for network related equipment (such as: AC ONU / communication ONU / intelligent ONU / fiber ONU/XPON ONU/GPON ONU etc.) . For every customer customize the exclusive demands who need it, also let our products more intelligent and advanced.