0 votes 0 votes #include<stdio.h> int main() { int a = 5; switch(a) { default: a = 4; case 6: a--; case 5: a = a+1; case 1: a = a-1; } printf("%d \n",a); return 0; } (a) 5 (b) 4 (c) 3 (d) None of these Programming in C output programming-in-c interview + – Desert_Warrior asked May 16, 2016 Desert_Warrior 8.9k views answer comment Share Follow See 1 comment See all 1 1 comment reply chandra sai commented Sep 26, 2017 reply Follow Share There is no break statement, so first a = a + 1 is executed, then a = a-1 is executed. 0 votes 0 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes Answer 5 since case 5 is executed a=6 then as their is no break case 1 also executes so a=5 again So a=5 is printed since case 5 is satisfied default doesn't execute shivanisrivarshini answered May 16, 2016 • selected May 16, 2016 by srestha shivanisrivarshini comment Share Follow See 1 comment See all 1 1 comment reply ankit commented Sep 16, 2016 reply Follow Share Here after case 5 , case 1 executed... So it means when a break statement is not given in any case then after that case all other cases also executes.. It doesn't matter condition is satisfied or not with switch or not?... Please clear my doubt ?? 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes the output of the given programm: They have not mention the break for any of the case so the default case also not execute ,If we put break in case 5 the answer will be "6". for refrence check thie link: http://codepad.org/nQifZJsR jaiganeshcse94 answered Aug 31, 2016 • edited Aug 31, 2016 by jaiganeshcse94 jaiganeshcse94 comment Share Follow See all 0 reply Please log in or register to add a comment.