adplus-dvertising

Welcome to the Control Flow Statements in C MCQs Page

Dive deep into the fascinating world of Control Flow Statements in C with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Control Flow Statements in C, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Control Flow Statements in C, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Control Flow Statements in C. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Control Flow Statements in C. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Control Flow Statements in C MCQs | Page 3 of 32

Explore more Topics under C Programming

Q21.
What is the output of this C code(when 1 is entered)?
#include <stdio.h>
    void main()
    {
        double ch;
        printf("enter a value btw 1 to 2:");
        scanf("%lf", &ch);
        switch (ch)
        {
        case 1:
            printf("1");
            break;
        case 2:
            printf("2");
            break;
        }
    }
Discuss
Answer: (a).Compile time error
Q22.
What is the output of this C code(When 1 is entered)?
#include <stdio.h>
    void main()
    {
        char *ch;
        printf("enter a value btw 1 to 3:");
        scanf("%s", ch);
        switch (ch)
        {
        case "1":
            printf("1");
            break;
        case "2":
            printf("2");
            break;
        }
    }
Discuss
Answer: (b).Compile time error
Q23.
What is the output of this C code(When 1 is entered)?
#include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value btw 1 to 2:");
        scanf("%d", &ch);
        switch (ch)
        {
        case 1:
            printf("1\n");
        default:
            printf("2\n");
        }
    }
Discuss
Answer: (c).1 2
Q24.
What is the output of this C code(When 2 is entered)?
#include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value btw 1 to 2:");
        scanf("%d", &ch);
        switch (ch)
        {
        case 1:
            printf("1\n");
            break;
            printf("hi");
        default:
            printf("2\n");
        }
    }
Discuss
Answer: (d).2
Q25.
What is the output of this C code(When 1 is entered)?
#include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value btw 1 to 2:");
        scanf("%d", &ch);
        switch (ch, ch + 1)
        {
        case 1:
            printf("1\n");
            break;
        case 2:
            printf("2");
            break;
        }
    }
Discuss
Answer: (b).2
Q26.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int a = 1, b = 1;
        switch (a)
        {
        case a*b:
            printf("yes ");
        case a-b:
            printf("no\n");
            break;
        }
    }
Discuss
Answer: (c).Compile time error
Q27.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int x = 97;
        switch (x)
        {
        case 'a':
            printf("yes ");
            break;
        case 97:
            printf("no\n");
            break;
        }
    }
Discuss
Answer: (c).Duplicate case value error
Q28.
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        float f = 1;
        switch (f)
        {
        case 1.0:
            printf("yes\n");
            break;
        default:
            printf("default\n");
        }
    }
Discuss
Answer: (d).Compile time error
Q29.
What is the output of this C code?
#include <stdio.h>
    const int a = 1,  b = 2;
    int main()
    {
        int x = 1;
        switch (x)
        {
        case a:
            printf("yes ");
        case b:
            printf("no\n");
            break;
        }
    }
Discuss
Answer: (d).Compile time error
Q30.
What is the output of this C code?
#include <stdio.h>
    #define max(a) a
    int main()
    {
        int x = 1;
        switch (x)
        {
        case max(2):
            printf("yes\n");
        case max(1):
            printf("no\n");
            break;
        }
    }
Discuss
Answer: (c).no

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!