Lesson 7: Nested If Statements

Homework: http://beginnerscpp.com/forums/index.php/topic,61.0.html



Nested If Statements
Despite the title of this lesson, I did very little in the way of showing you nested if statements, and the reason why I opted to teach it this way was because I wanted to show that intelligent program design can get away from nesting. Sometimes nesting is unavoidable, and for those cases the following syntax remains true

The only thing that I can advise you on when it comes to nested if statements is that you should be EXTREMELY strict when it comes to your indenting. Furthermore, some people like to document their code to remind them which if statement they are in, however I find this type of commenting somewhat excessive. A comment here and there to remind us what something does, or what we’re testing is fine, but when you see something like this, it’s a bit excessive.

While I understand the intention of the person that made the comments, it actually adds to confusion over stating the implied usage on a single line like this:


Lesson 6: Simple if structure
Lesson 8: Hard Debugging