Decision Making


  1. Which datatype can accept switch statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    None of these


  1. Comment on the output of the following C code.
     #include <stdio.h>
    int main()
    {
    int num = 2;
    switch (num)
    case 1:
    printf("%d", num);
    case 2:
    printf("%d", num);
    case 3:
    printf("%d", num);
    default:
    printf("%d", num);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Compile time error, case label outside switch statement



  1. Which of the following errors would be reported by the compiler on compiling the program given below?
    #include <studio.h>
    int main ( )
    {
    int a = 5;
    switch (n)
    {
    case 1 :
    ..
    case 2 :
    ..
    case 3 + 5 :
    ..
    case a :
    ..
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    Variables cannot be checked using a switch as in case a.

    Correct Option: A

    Variables cannot be checked using a switch as in case a.


  1. What will be the output of the following C code?
    #include <stdio.h>
    #define max(p) p
    int main()
    {
    int n = 1;
    switch (n)
    {
    case max(2):
    printf("Right...\n");
    case max(1):
    printf("Wrong...\n");
    break;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Wrong...



  1. What will be the output of the following C code?
      #include <stdio.h>
    const int n = 10, m = 12;
    int main()
    {
    int P = 10;
    switch (P)
    {
    case n:
    printf("Yes...");
    case m:
    printf("No...\n");
    break;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Yes... No...