Question 9: Show output II [10]

Show the output that would result from running the program below.

#include <cstdio>

enum States {
   fetching, decoding, executing, done
};

void execute(int i);

int main()
{
   States myState = fetching;
   int statementNumber = 0;

   while (myState != done) {
      switch(myState) {
         case fetching:
            printf("Fetching instruction %d\n", statementNumber);
            myState = decoding;
            break;
         case executing:
            printf("Executing\n");
            execute(statementNumber);
            myState = done;
            if (statementNumber < 2) {
               statementNumber++;
               myState = fetching;
            }
            break;
         case decoding:
            printf("Decoding\n");
            myState = executing;
         default:
            myState = done;
            break;
      }
   }
}

void execute(int i)
{
   switch (i) {
      case 1: printf("Look out for number 1 but\n");
              // note no break
      case 2: printf("But do not step in number 2\n");
              break;
      case 3: printf("So this is what a computer does?\n");
              break;
      default: printf("Error line %d\n", i);
              break;
   }
}