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?
Image of page 38
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?
Image of page 39
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?
Image of page 40
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?
Image of page 41
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?
Image of page 42
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?
Image of page 43
44 Hand Trace int main ( void ) {
Image of page 44
Image of page 45

You've reached the end of your free preview.

Want to read all 47 pages?

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

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes