Join Dan Gookin for an in-depth discussion in this video Looping with while, part of Learning C.
- Another way that program flow can be altered…is when one or more statements are repeated over and over.…This process is referred to as a loop.…The C language offers several ways of looping.…In this movie, I present the 'while' type of loop.…You'll learn how to set up the loop,…determine when to stop looping,…and how to break out of a loop before it's done.…A loop is a repetitive way to control program execution.…You must specify a condition that makes the loop repeat,…a set of statements that repeat,…and a way for the loop to stop.…
In this code, a 'while' loop counts from one to 10.…The looping condition is specified on line eight.…It reads that, while the value of variable x…is less than or equal to 10,…as long as that condition is true,…the statements in the loop between the curly brackets…at line nine and 12 will repeat.…The value of x is initialized at line seven.…
At line 11, the value of variable x is incremented.…So, as long as x keeps inching up, the loop repeats…until x is greater than 10.…Build and run this code.…
- Understanding a C program
- Adding comments
- Using escape characters
- Working with values and placeholders
- Introducing variables
- Making a decision with if
- Adding functions
- Manipulating strings
- Building arrays
- Nesting structures
Skill Level Beginner
1. Getting Started
2. Programming Basics
3. Program Flow Control
4. Intermediate C Language Concepts
5. Advanced C Language Concepts
Next steps2m 11s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.