c - what is output ? gcc output is 0. please explain? -


this question has answer here:

gcc compiler output 0. why? shouldn't 3?

int main() {     f(3);     return 0; }  int f(int t) {     int c;      switch(t)     {     case 2:         c=2;     case 3:         c=3;     case 4:         c=4;     case 5:         c=5;     default:         c=0;     }     printf("%d",c); } 

because missing break; statement in each of cases. leads control falling through following case statements , default case.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -