[Prev][Next][Index]

default option in a switch statement.




1. For the following switch statement:

      switch (i)
      {
         case 10:
         printf("The value of i is %d", i);
         printf("The value of j is %d", j);
         break;
         case 20:
         printf("The value of k is %d", i);
         printf("The value of l is %d", j);
         break;
         default:
         printf("xxxxxxxxxxxxx");
       }
2. The following fragment:

    for (int i=0; i < H->numberOfCaseOptions(); i++){
      H->caseOption(i)->unparsestdout();
      H->caseOption(i)->nextInChildList()->unparsestdout();
      if (i == H->numberOfCaseOptions()-1)
        H->lastExecutable()->unparsestdout();
      else
        H->caseOption(i+1)->nodeBefore()->unparsestdout();
    }

3. Gave the following output:

case 10:
printf("The value of i is %d", i);
break;
case 20:
printf("The value of k is %d", i);
printf("xxxxxxxxxxxxx");


4. Looks like the default case is not considered as a caseOption().

Rahul