Much like we discussed in Flowcharts, in pseduocode, we can also nest our conditions. That means that within the body of one true statement, or the else, false statement, we can nest a whole new decision.
A simple case is where we want to see if two things are both true, and we don’t know about Boolean operations yet. So, for example, we might want to test to see if you are over 16 years old, and thus old enough to drive. However, you also need a driver’s licence to drive. So you check that in a second, nested condition, never asking, if person is under 16, because it isn’t relevant to them.
age = 18
hasLicense = true
if age >= 16 then
if hasLicense = true then
print "You are old enough to drive, and you have a license. You can drive."
end
Also, you don’t have to only have the nested condition, you have have additional statements.
age = 18
hasLicense = true
if age >= 16 then
print "Excellent, you are old enough to drive."
if hasLicense = true then
print "You have a license. You can drive."
end
Nested conditions are nice, because you can write else clauses for each.
age = 18
hasLicense = true
if age >= 16 then
print "Excellent, you are old enough to drive."
if hasLicense = true then
print "You have a license. You can drive."
else
print "You must have a license to drive."
else
print "You must be 16 or older to have your operator's permit."
end
Nested Conditions in Pseudocode was originally found on Access 2 Learn