Class 6 Exam  >  Class 6 Tests  >  C Programming for Beginners  >  Test: C Switch Case - Class 6 MCQ

Test: C Switch Case - Class 6 MCQ


Test Description

15 Questions MCQ Test C Programming for Beginners - Test: C Switch Case

Test: C Switch Case for Class 6 2024 is part of C Programming for Beginners preparation. The Test: C Switch Case questions and answers have been prepared according to the Class 6 exam syllabus.The Test: C Switch Case MCQs are made for Class 6 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: C Switch Case below.
Solutions of Test: C Switch Case questions in English are available as part of our C Programming for Beginners for Class 6 & Test: C Switch Case solutions in Hindi for C Programming for Beginners course. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free. Attempt Test: C Switch Case | 15 questions in 15 minutes | Mock test for Class 6 preparation | Free important questions MCQ to study C Programming for Beginners for Class 6 Exam | Download free PDF with solutions
Test: C Switch Case - Question 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;
}

Detailed Solution for Test: C Switch Case - Question 1

Absence of break; after case statement causes control to go to next case automatically. So after matching 3 with a==3, program prints 3 and control falls down the ladder without checking case again printing everything below it. So Switch checks only once and falls down.

Test: C Switch Case - Question 2

What is the output of C Program with switch statement or block?

int main()
{
    int a=3;
    
    switch(a)
    {

    }
    
    printf("MySwitch");
}

Detailed Solution for Test: C Switch Case - Question 2

Yes, It is okay to omit CASE: statements inside SWITCH construct or block.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: C Switch Case - Question 3

What is the output of C program with switch statement or block?

int main()
{
    int a;
    
    switch(a);
    {
        printf("DEER ");
    }
    
    printf("LION");
}

Detailed Solution for Test: C Switch Case - Question 3

Notice a semicolon at the end of switch(a);. So, printf DEER is out of SWITCH.

    switch(a)
    {
        ;
    }
    
    {
        printf("DEER ");
    }

Test: C Switch Case - Question 4

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");
}

Detailed Solution for Test: C Switch Case - Question 4

Any character is replaced by ASCII code or number by the compiler. So it is allowed to use CHARACTER constants for CASE constants.

Test: C Switch Case - Question 5

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");
}

Detailed Solution for Test: C Switch Case - Question 5

ASCII value of 'A' is 65. So (64+1) matches A. Also expression leading to Integers can be used as CASE Constants.

Test: C Switch Case - Question 6

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");
}

Detailed Solution for Test: C Switch Case - Question 6

You can not use comparison operations with CASE statements in SWITCH.

Test: C Switch Case - Question 7

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");
}

Detailed Solution for Test: C Switch Case - Question 7

You can not use CONTINUE; statement as SWITCH is not a LOOP like for, while and do while.

Test: C Switch Case - Question 8

What is the output of C Program with switch statement?

Detailed Solution for Test: C Switch Case - Question 8

Notice that it is "default" not "case default".

Test: C Switch Case - Question 9

What is the output of C Program with switch statement or block?
int main()
{
    int a;
    
    switch(a)
    {
        printf("APACHE ");
    }
    
    printf("HEROHONDA");
}

Detailed Solution for Test: C Switch Case - Question 9

Notice the missing CASE or DEFAULT statements. Still compiler accepts. But without CASE statement nothing will be printed inside of SWITCH.

    switch(a)
    {
        printf("APACHE ");
    }
 

Test: C Switch Case - Question 10

What is the output of C Program with switch statement or block?

Detailed Solution for Test: C Switch Case - Question 10

After matching 5, FIVE will be printed. BREAK causes control to exit SWITCH immediately. Also, using a STATIC variable is also allowed.

Test: C Switch Case - Question 11

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");
}

Detailed Solution for Test: C Switch Case - Question 11

You can not use STRING constants with DOUBLE QUOTES as CASE constants. Only expressions leading or constants leading to Integers are allowed.

Test: C Switch Case - Question 12

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");
}

Detailed Solution for Test: C Switch Case - Question 12

You can not use DUPLICATE SWITCH Case Constants. 64 == (8*).

Test: C Switch Case - Question 13

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");
}

Detailed Solution for Test: C Switch Case - Question 13

(1==8) is false i.e 0. (1&&2) is true AND true i.e true i.e 1. So case allowed first ZERO 0 and then ONE 1. All integer constants are allowed for SWITCH Case Constants.

Test: C Switch Case - Question 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");
}

Detailed Solution for Test: C Switch Case - Question 14

You can not use float, double or Strings inside Switch or Switch CASE.

Test: C Switch Case - Question 15

Choose a correct statement about a C Switch Construct.

10 videos|13 docs|15 tests
Information about Test: C Switch Case Page
In this test you can find the Exam questions for Test: C Switch Case solved & explained in the simplest way possible. Besides giving Questions and answers for Test: C Switch Case, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 6

10 videos|13 docs|15 tests
Download as PDF

Top Courses for Class 6