From the course: C Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Setting up a while loop

Setting up a while loop - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Setting up a while loop

- [Instructor] The C language keyword while, constructs a loop of one or more repeating statements. The keyword is followed by parentheses containing the looping expression, while this expression evaluates true, the statements repeat. And similar to other C constructions, when more than a single statement is repeated, they must be enclosed in braces. Unlike a for loop, the while loop statement contains, only the while true looping condition, which must remain true for the statements to repeat. The loop's condition must be initialized before the loop starts as a separate statement. Further, the loop's statements must contain its exit strategy. Something that alters the condition, the while statement evaluates. The while loop in this exercise file, repeats 10 times. Variable a is initialized to zero at line seven. The loop's statements repeat as long as the value of variable a is less than 10. Importantly, at line 11…

Contents