Looping in C
“The process of repeatedly executing a block of statements is known as looping”.
In looping, a sequence of statements is executed until some conditions for termination of the loop are satisfied. Generally, a program loop consists of two segments: (i)control statement (ii) Body of the loop.
(i) Control statement tests specified conditions and then directs the repeated execution of the statements contained in the body of the loop.
(ii) Body of the loop is a statement-block, which may consist of one statement or more statements.
The loop may be categories in the following two types depending on the position of the control statements:-
(ii)Exit-controlled Loop: In case of an exit-controlled loop, the control checks the test-condition after executing the body of the loop. Do-while() loop come under this.
(I) Entry controlled Loop: In case of an entry-controlled loop, the control checks the test-condition before entering into the body of the loop. While () and for() loop come under this category.
Now, we are going to discuss, types of loop statements provided by C Language. There are three types:
(a) While() Loop
(b) do-while() Loop
(c) For () Loop