What is while loop?

AnuragSrivastava272 50 views 6 slides Jun 22, 2020
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

This PPT is about the While loop, if you want to see in detail visit the Be a Programmer channel on YouTube.


Slide Content

What is while loop?

A while loop in C programming repeatedly executes a target statement as long as a given condition is true. The while loop is mostly used in the case where the number of iterations is not known in advance.

while(condition) { statement(s); } Syntax When the condition becomes false, the program control passes to the line immediately following the loop. false The loop iterates while the condition is true. true

Condition Conditional Code If condition is false If condition is true while(condition) { statement(s); }

Example on while loop!!

Properties of While loop Loop executes till the condition in it is true. 2. In while loop, the condition expression is compulsory. 3. Running a while loop without a body is possible. 4. We can have more than one conditional expression in while loop. 5. If the loop body contains only one statement, then the braces are optional.