GATE CSE
First time here? Checkout the FAQ!
x
0 votes
92 views
#include

int main()

{ char check = 'a';

switch (check)

{

case 'a' || 1: printf("Gates ");

case 'b' || 2: printf("Quiz ");

break;

default: printf("GatesQuiz");

} return 0; }

(a) Gates

(b) Gates Quiz

(c) Gates Quiz GatesQuiz

(d) Compile-time error
asked in Programming by Veteran (13.2k points)   | 92 views

1 Answer

0 votes
i think  ryt option is "D" bcoz 'a'||1 will evaluate to 1 and 'b'||2 will also evaluate to 1 so both the case will become same .

and in swicth case every case must be unique so it will generate compile time error.
answered by Junior (643 points)  
Compile time error


Top Users Aug 2017
  1. Bikram

    3584 Points

  2. ABKUNDAN

    3404 Points

  3. akash.dinkar12

    3030 Points

  4. manu00x

    2446 Points

  5. rahul sharma 5

    2260 Points

  6. makhdoom ghaya

    2040 Points

  7. just_bhavana

    1880 Points

  8. Tesla!

    1596 Points

  9. pawan kumarln

    1574 Points

  10. learner_geek

    1504 Points


24,796 questions
31,868 answers
73,708 comments
30,011 users