A while loop repeats as long as the condition specified remains true, though it requires overhead in that its initialization and exit conditions must take place independently of the while statement. It's important to remember to initialize the looping condition before the while loop statement as well as provide an exit condition somewhere within the 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, variable a is modified, …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- 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.