switch(j) //j must be of an integer type
{
case 1: //what j equals. if j ==1, do things...
x=a+b;
break; //if you leave breaks off it does the next one. so if j=1 you would get x - a-b here without...
case 2:
x = a-b;
// etc...
Note the use of a break statement at the end of each case. Once the switch variable (j) matches a case, all statements in all subsequent cases are executed. Remove one or two of the break statements to see what happens.