Types of Loops in C Depending upon the position of a control statement in a program, looping statement in C is classified into two types: 1. Entry controlled loop 2. Exit controlled loop In an entry control loop in C, a condition is checked before executing the body of a loop.
Loop Type Description 1. While Loop In while loop, a condition is evaluated before processing a body of the loop. Do-While Loop In a do…while loop, the condition is always executed after the body of a loop. For Loop In a for loop, the initial value is performed only once, then the condition tests and compares the counter to a fixed value after each iteration, stopping the for loop when false is returned.
Report a Bug. Previous Prev. Next Continue. Home Testing Expand child menu Expand. SAP Expand child menu Expand. Web Expand child menu Expand. Must Learn Expand child menu Expand. Big Data Expand child menu Expand. Live Project Expand child menu Expand. AI Expand child menu Expand. Machine Learning.
Data Structures. Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. The process goes on until testExpression is evaluated to false.
If testExpression is false , the loop terminates ends. Hence, the body of the while loop is executed. This prints 1 on the screen and the value of i is increased to 2. The body of the while loop is executed again. This prints 2 on the screen and the value of i is increased to 3. This process goes on until i becomes 6.
Table of Contents while Loop Example: while Loop do Previous Tutorial:. Next Tutorial:. Share on:. Did you find this article helpful? Sorry about that. How can we improve it? Download Microsoft Edge More info. Contents Exit focus mode. Is this page helpful? Yes No. Any additional feedback?
0コメント