AnuragSrivastava272
50 views
6 slides
Jun 22, 2020
Slide 1 of 6
1
2
3
4
5
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.
Size: 100.34 KB
Language: en
Added: Jun 22, 2020
Slides: 6 pages
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.