Join Dan Gookin for an in-depth discussion in this video Nested loops, part of Up and Running with C.
- View Offline
- Exercise Files
- One thing you can do with a 'for loop'…that's a lot easier than using a 'while loop'…is the concept of the 'nested loop'.…In this movie I'll show you how to create a 'nested loop',…and how to avoid endless loops in common looping mistakes.…This code sends 10 random numbers to output,…built and run to see what it does.…You see a neat row of ten random values.…The spacing is produced by the tab character,…shown on line 14 as backslash T is the tab character.…
To make a grid of 100 random values,…you need to add nine more rows.…The way C programmers accomplish this task is…to create a nested loop or a second 'for loop'…that handles repeating the current output 10 times.…Or nine times actually plus the current one.…Open the exercise Nested For One.…This code is a modification to the previous excercise.…It includes, an extra loop, the old loop, the common loop,…is now nested inside the row loop.…
The indentation keeps the code readable,…but also helps match up the statements in curly brackets.…Build and run this code, and you see 100 random numbers.…
- 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.