Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Loops & Control Structure | Question 16

  • Difficulty Level : Medium
  • Last Updated : 28 Jun, 2021

What is the output of the following program?

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




#include <stdio.h>
int main()
{
    char check = 'a';
    switch (check)
    {
        case 'a' || 1: printf("Geeks ");
          
        case 'b' || 2: printf("Quiz ");
                    break;
        default: printf("GeeksQuiz");
    }
    return 0;
}

(A) Geeks
(B) Geeks Quiz
(C) Geeks Quiz GeeksQuiz
(D) Compile-time error


Answer: (D)

Explanation: An expression gets evaluated in a case label. Both the cases used are evaluated to 1(true). So compile-time error: duplicate case value is flashed as duplicated cases are not allowed.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!