But when I started writing the second part of this series, wouldn t you know that one of the first constructs I needed was best shown as a case construction. So, allow me to back up a little and cover the case and switch constructs. Depending on a value of a variable, different tasks may need to be performed. Let s say that the keyboard s input of 0 to 9 is to perform 10 different functions. Listing 1 is an example of what you could code until all the cases are covered.
Most languages have a switch or case statement.
And in C, it goes something like what you see in Listing 2 . The Nassi Schneiderman construction can be seen in Figure 1. Here you can see the switch, or case, construction set up as a Nassi Schneiderman chart. But, you can see that this construction has only one input and one output. And depending on the switch variable, only one set of processes are followed.