I f- Then- Else

Olivia

Verified seller
Staff member
Verified Trusted Seller
Nov 13, 2018
1,249
425
113
russiancarders.se
#1
I n the case of our driving directions, Main Street could be under construction. I f it is, a special set of instructions needs to address that situation. Otherwise, the original set of instructions should be followed. These types of special cases can be accounted for in a program with one of the m ost natural controlstructures: the if-then-else structure. I n general, it looks som ething like this: If (condition) then { Set of instructions to execute if the condition is met; } Else { Set of instruction to execute if the condition is not met; } For this book, a C-like pseudo-code will be used, so every instruction will end with a sem icolon, and the sets of instructions will be grouped with curly braces and indentation. The if-then-else pseudo-code structure of the preceding driving directions m ight look som ething like this: Drive down Main Street; If (street is blocked) { Turn right on 15th Street; Turn left on Pine Street; Turn right on 16th Street; } Else { Turn right on 16th Street; }
 

Log in

Online statistics

Members online
0
Guests online
43
Total visitors
43