Computer Science Canada [Ada-tut] Control Structures: If ... Else |
Author: | wtd [ Mon Oct 11, 2004 5:36 pm ] | ||||
Post subject: | [Ada-tut] Control Structures: If ... Else | ||||
Background In many programs there will be a time when you need to make a choice and do one of two or more possibilities based on the values of the variables at that point in the program. Generally we call this a "conditional", and the usual words associated with it are "if" and "else". Ada is no different, except that we can have more than just two choices, and for the "in between" choices we use "elsif". A simple example So, let's look at a simple example. In thise example we'll compare 8 to 8. If they're the same, then all is well with the universe. If they're not, then the laws of mathematics have gone out the window.
Another choice If 8 equals 7, then the universe is almost right.
You can include as many "elsif" conditions as necessary. |