The while Loop is an entry-controlled loop in C programming language. This loop can be used to iterate a part of code while the given condition remains true.
while (test expression) { // body consisting of multiple statements }
1. STEP 1: When the program first comes to the loop, the test condition will be evaluated. 2. STEP 2A: If the test condition is false, the body of the loop will be skipped program will continue. 3. STEP 2B: If the expression evaluates to true, the body of the loop will be executed. 4. STEP 3: After executing the body, the program control will go to STEP 1. This process will continue till the test expression is true.
An infinite while loop is created when the given condition is always true. It is encountered by programmers in when: • The test condition is incorrect. • Updation statement not present.
Program.c
output.c
With supporting text below as a natural lead-in to additional content.