The switch case statement is the construct of choice if the program must branch more than two ways at a point in the source code. For only two branches, the if statement works well. The switch case construct works like this:
int intNumber = 2; switch( intNumber) { case 0: // Do something. break; case 1: // Do something. break; case 2: // Do something. break; case 3: // Do something. break; default: // Do something. }
The default case is optional.