Join Dan Gookin for an in-depth discussion in this video Solution: Output a series of numbers, part of Learning C.
(swishing)…- Here are the solutions to the three challenges.…The first was to modify the code…so that values one through 20 were output…and the change is really simple.…You just change the 10 to a 20.…Save that change.…Build and run, and there's the numbers one through 20.…The second challenge was to modify the code…so that even values two through 20 are output,…unlike a While loop, which was shown in an earlier movie,…only one line needs to be changed.…
Initialization needs to change…so that x equals 1 and then x equals x plus 2.…Save, build and run, and there are the even numbers.…Of course, to make it more readable,…I'd probably have done this change, where x equals 2,…while x is less than or equal to 20.…Then change the printf statement so that x is output itself.…
That's just more readable than doing it the other way.…The final challenge was to modify the code…to display values 10, nine, eight, all the way down to one.…Here's how that change would be made.…First, x must be initialized to 10.…And then the loop must spin while x is greater than zero.…
- 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.