Regularity
From Maze
(Difference between revisions)
(→Iteration: Added section of the flow of control in imperitive programs) | (→The Flow of Control) | ||
| Line 15: | Line 15: | ||
The result is | The result is | ||
| − | FIRST | + | FIRST<br /> |
SECOND | SECOND | ||
Because the command on the left is executed first; then, the command on the right is carried out. In executing the following program, the topmost, leftmost command is run first, then the one to the right, and then the one on the next line, printing three lines that read FIRST, SECOND, and THIRD: | Because the command on the left is executed first; then, the command on the right is carried out. In executing the following program, the topmost, leftmost command is run first, then the one to the right, and then the one on the next line, printing three lines that read FIRST, SECOND, and THIRD: | ||
| − | 10 PRINT "FIRST": PRINT "SECOND" | + | 10 PRINT "FIRST": PRINT "SECOND"<br /> |
20 PRINT "THIRD" | 20 PRINT "THIRD" | ||
| Line 29: | Line 29: | ||
In BASIC, the IF ... THEN ... statement is used to branch conditionally, so that different code is executed depending upon the value of an expression: | In BASIC, the IF ... THEN ... statement is used to branch conditionally, so that different code is executed depending upon the value of an expression: | ||
| − | 10 INPUT A$ | + | 10 INPUT A$<br /> |
| − | 20 IF A$ = "1" THEN PRINT "FIRST" : END | + | 20 IF A$ = "1" THEN PRINT "FIRST" : END<br /> |
30 PRINT "SOMETHING ELSE" | 30 PRINT "SOMETHING ELSE" | ||
