1 votes 1 votes What is the output of the following program? #include <stdio.h> int main() { int a = 0; switch(a) { default: a = 4; case 6: a--; case 5: a = a+1; case 1: a = a-1; } printf("%d \n",a); return 0; } Programming in C tbb-programming-2 numerical-answers + – Bikram asked May 14, 2017 edited Aug 19, 2019 by Counsellor Bikram 292 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes when the value of a matches with none of the cases, then the default value of 4 gets assigned to a and a "fallthrough" happens since there is no "break" statement. Hence, all the expressions involving a gets executed and the resulting value is 3 Abhisek Das answered Jun 27, 2017 selected Jun 27, 2017 by Bikram Abhisek Das comment Share Follow See all 0 reply Please log in or register to add a comment.