1) What would be printed if the user entered the word "camel" <return> ^d?
char character; /* one character */
printf( "Enter a word.\n" );
printf( "Enter the EOF character to end input.\n" );
/* loop until user types end-of-file key sequence */
while ( ( character = getchar() ) != EOF ) {
/* determine which grade was input */
switch ( character ) { /* switch nested in while */
case 'A':
case 'a':
printf("Case for (a)\n");
case 'E':
case 'e':
printf("Case for (e)\n");
break; /* exit switch */
case 'I':
case 'i':
printf("Case for (i)\n");
case 'O':
case 'o':
printf("Case for (o)\n");
break; /* exit switch */
case 'U':
case 'u':
printf("Case for (u)\n");
break; /* exit switch */
case '\n': /* ignore newlines, */
case '\t': /* tabs, */
case ' ': /* and spaces in input */
printf("Case for white-space character\n");
break; /* exit switch */
default: /* catch all other characters */
printf( "default case for nonvowel.\n" );
break; /* optional; will exit switch anyway */
} /* end switch */
} /* end while */
2) Draw a flow diagram for the above switch statement.