switch total case 2 printfhellon break case 3 printfgood byen break default

# Switch total case 2 printfhellon break case 3

This preview shows page 38 - 45 out of 47 pages.

switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 && Output: Given this code, what is the output?
39 Hand Trace int main ( void ) {    int a=3, b=4, c=5, d=6,total=2;    if( a<b  &&  c>d )      total = 3;    else      total = 4;     switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 T F && Output: Given this code, what is the output?
40 Hand Trace int main ( void ) {    int a=3, b=4, c=5, d=6,total=2;    if( a<b  &&  c>d )      total = 3;    else      total = 4;     switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 T F && F 4 Output: Given this code, what is the output?
41 Hand Trace int main ( void ) {    int a=3, b=4, c=5, d=6,total=2;    if( a<b  &&  c>d )      total = 3;    else      total = 4;     switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 T F && F 4 Output: Given this code, what is the output?
42 Hand Trace int main ( void ) {    int a=3, b=4, c=5, d=6,total=2;    if( a<b  &&  c>d )      total = 3;    else      total = 4;     switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 T F && F 4 False Output: Given this code, what is the output?
43 Hand Trace int main ( void ) {    int a=3, b=4, c=5, d=6,total=2;    if( a<b  &&  c>d )      total = 3;    else      total = 4;     switch (total) {       case 2:          printf(“hello\n”);          break;       case 3:          printf(“good-bye\n”);          break;       default:          printf(“so long\n”);       } }       a b c d total a<b c>d 3 4 5 6 2 T F && F 4 False Output: Given this code, what is the output?
44 Hand Trace int main ( void ) {

#### You've reached the end of your free preview.

Want to read all 47 pages?

• Spring '10
• baleh
• sentinel value, SENTINEL, Decrement Operators