C MCQ Questions and Answers on Switch Case Syntax

Image

Learn C Programming MCQ Questions and Answers on Switch Case Syntax. Switch case takes only integers. Each Case can check for only Equals To operation. Easily attend exams after reading these Multiple Choice Questions.

Go through C Theory Notes on Switch Case before studying questions.



1) What is the output of C Program with Switch Statement.?
int main()
{
    
    int a=5;
    
    switch(a)
    {
        case 0: printf("0 ");
        case 3: printf("3 ");
        case 5: printf("5 ");
        default: printf("RABBIT ");
    }
    
    a=10;
    switch(a)
    {
        case 0: printf("0 ");
        case 3: printf("3 ");
        case 5: printf("5 ");
        default: printf("RABBIT "); break;
    }
    
    return 0;
}
A) 5 RABBIT
B) 0 3 5 RABBIT 0 3 5 RABBIT
C) 0 3 5 RABBIT RABBIT
D) 3 5 RABBIT RABBIT
Answer [=]
Answer[=]
2) What is the output of C Program with switch statement.?
int main()
{
    int a=3;
    
    switch(a)
    {
        case 2: printf("ZERO "); break;

        case default: printf("RABBIT ");
    }
    
}
A) RABBIT
B) ZERO RABBIT
C) No output
D) Compiler error
Answer [=]
Answer[=]
3) What is the output of C Program with switch statement or block.?
int main()
{
    int a=3;
    
    switch(a)
    {

    }
    
    printf("MySwitch");
}
A) MySwitch
B) No Output
C) Compiler Error
D) None of the above
Answer [=]
Answer[=]
4) What is the output of C Program with switch statement or block.?
int main()
{
    int a;
    
    switch(a)
    {
        printf("APACHE ");
    }
    
    printf("HEROHONDA");
}
A) APACHE HEROHONDA
B) HEROHONDA
C) No Output
D) Compiler error
Answer [=]
Answer[=]
5) What is the output of C program with switch statement or block.?
int main()
{
    int a;
    
    switch(a);
    {
        printf("DEER ");
    }
    
    printf("LION");
}
A) LION
B) DEER LION
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
6) What is the output of C Program with switch statement or block.?
int main()
{
    static int a=5;
    
    switch(a)
    {
        case 0: printf("ZERO ");break;
        case 5: printf("FIVE ");break;
        case 10: printf("DEER ");
    }
    
    printf("LION");
}
A) ZERO FIVE DEER LION
B) FIVE DEER LION
C) FIVE LION
D) Compiler error
Answer [=]
Answer[=]
7) What is the output of C program with switch statement or block.?
int main()
{
    char code='K';
    
    switch(code)
    {
        case 'A': printf("ANT ");break;
        case 'K': printf("KING "); break;
        default: printf("NOKING");
    }
    
    printf("PALACE");
}
A) KING PALACE
B) KING NOTHING PALACE
C) ANT KING PALACE
D) Compiler error for using Non Integers as CASE constants.
Answer [=]
Answer[=]


 

8) What is the output of C Program with switch statement or block.?
int main()
{
    char code='K';
    
    switch(code)
    {
        case "A": printf("ANT ");break;
        case "K": printf("KING "); break;
        default: printf("NOKING");
    }
    
    printf("PALACE");
}
A) ANT KING PALACE
B) KING PALACE
C) PALACE
D) Compiler error
Answer [=]
Answer[=]
9) What is the output of C Program with switch statement or block.?
int main()
{
    char code='A';
    
    switch(code)
    {
        case 64+1: printf("ANT ");break;
        case 8*8+4: printf("KING "); break;
        default: printf("NOKING");
    }
    
    printf("PALACE");
}
A) ANT KING PALACE
B) KING PALACE
C) ANT PALACE
D) Compiler error for using expressions
Answer [=]
Answer[=]
10) What is the output of C Program with switch statement or block.?
int main()
{
    char code=64;
    
    switch(code)
    {
        case 64: printf("SHIP ");break;
        case 8*8: printf("BOAT "); break;
        default: printf("PETROL");
    }
    
    printf("CHILLY");
}
A) SHIP CHILLY
B) BOAT CHILLY
C) BOAT PETROL CHILLY
D) Compiler error
Answer [=]
Answer[=]
11) What is the output of C Program with switch statement or block.?
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 [=]
Answer[=]
12) 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 [=]
Answer[=]
13) What is the output of C Program with switch statement or block.?
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 [=]
Answer[=]
14) What is the output of C Program with switch statement or block.?
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 [=]
Answer[=]


 

15) 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 [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Some good C Books

Book Price
1. C: The Complete Reference  Check Price
2. Let Us C Check Price
3. Programming in ANSI C Check Price
4. The C Programming Language Check Price

We may get some affiliate commission for the above purchases.