C MCQ Set-3 : Multiple Choice Questions in C Set-3

Set-26 C MCQ

  1. What is the output of C Program?

    int main()
    {
    int k=64;
    switch(k)
    {
    case k<64: printf(“SHIP “); break; case k>=64:
    printf(“BOAT “);
    break;
    default:
    printf(“PETROL”);
    }
    printf(“CHILLY”);
    }

    A) BOAT CHILLY
    B) BOAT PETROL CHILLY
    C) SHIP BOAT CHILLY
    D) Compiler error

    Answer D
    C MCQ Set-3 Explanation
  2. What is the output of C Program with switch statement or block?

    int main()
    {
    int k=8;
    switch(k)
    {
    case 1==8:
    printf(“ROSE “);
    break;
    case 1 && 2:
    printf(“JASMINE “);
    break;
    default:
    printf(“FLOWER “);
    }
    printf(“GARDEN”);
    }

    A) ROSE GARGEN
    B) JASMINE GARDEN
    C) FLOWER GARDEN
    D) Compiler error

    Answer C
    C MCQ Set-3 Explanation

  3. What is the output of C Program?

    int main() {
    int k=25;
    switch(k) {
    case 24:
    printf(“ROSE “);
    break;
    case 25:
    printf(“JASMINE “);
    continue;
    default:
    printf(“FLOWER “);
    }
    printf(“GARDEN”);
    }

    A) JASMINE GARDEN
    B) JASMINE FLOWER GARDEN
    C) FLOWER GARDEN
    D) Compiler error

    Answer D
    C MCQ Set-3 Explanation

  4. What is the output of C Program with switch statement?

    int main() {
    switch(24.5) {
    case 24.5:
    printf(“SILVER “);
    break;
    case 25.0:
    printf(“GOLD “);
    break;
    default:
    printf(“TIN “);
    }
    printf(“COPPER”);
    }

    A) SILVER COPPER
    B) TIN COPPER
    C) COPPER
    D) Compiler error

    Answer D
    C MCQ Set-3 Explanation
  5. Choose a correct statement about a C Switch Construct.

    A) default case is optional inside switch.
    B) break; causes the control to exit the switch immediately and avoid fall down to other CASE statements.
    C) You can not use duplicate CASE Constants inside a Switch construct.
    D) All the above.

    Answer D
    C MCQ Set-3 Explanation
  6. What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input)

    int main()
    {
    int ch;
    printf(“enter a value between 1 to 2:”);
    scanf(“%d”, &ch);
    switch (ch)
    {
    case 1:
    printf(“1\n”);
    break;
    printf(“hi”);
    default:
    printf(“2\n”);
    }
    return 0;
    }

    a) 1
    b) hi 2
    c) Run time error
    d) 2

    Answer D
    C MCQ Set-3 Explanation

  7. What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

    int main()
    {
    int ch;
    printf(“enter a value between 1 to 2:”);
    scanf(“%d”, &ch);
    switch (ch, ch + 1)
    {
    case 1:
    printf(“1”);
    break;
    case 2:
    printf(“2”);
    break;
    }
    return 0;
    }

    a) 1
    b) 2
    c) 3
    d) Run time error

    Answer B
    C MCQ Set-3 Explanation

  8. What will be the output of the following C code?

    int main()
    {
    int x = 97;
    switch (x)
    {
    case ‘a’:
    printf(“yes “);
    break;
    case 97:
    printf(“no\n”);
    break;
    }

    a) yes
    b) yes no
    c) Duplicate case value error
    d) Character case value error

    Answer C
    C MCQ Set-3 Explanation

  9. What will be the output of the following C code?

    int main()
    {
    printf(“%d “, 1);
    goto l1;
    printf(“%d “, 2);
    l1:goto l2;
    printf(“%d “, 3);
    l2:printf(“%d “, 4);
    return 0;
    }

    a) 1 4
    b) Compilation error
    c) 1 2 4
    d) 1 3 4

    Answer A

10. What will be the output of the following C code?
(Assuming that we have entered the value 1 in the standard input)

int main()
{
    double ch;
    printf("enter a value between 1 to 2:");
    scanf("%lf", &ch);
    switch (ch)
    {
       case 1:
          printf("1");
          break;
       case 2:
          printf("2");
          break;
    }
return 0;
}

a) Compile time error
b) 1
c) 2
d) Varies

Answer A


C MCQ Set-1
C MCQ Set-2
C MCQ Set-3
C MCQ SET 4

Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *