0
switch statement
alpha is 5 { case 1 case 2: alpha = 2 + alpha; break; case 4: alpha++; case 5: alpha = alpha * 2; case 6: alpha = alpha + 5; break; default alpha - -; } My question is what happens at ‘case 4’. Does it not suppose to increament if my lecture says the answer is 15 not 17. Or he made some mistakes
2 Respostas
0
nothing till it hits a match , so nothing at 4 , then
first it jumps to case 5 and alpha = 5*2=10, since no break it goes to case 6 too alpha = 10+5= 15, then we have break so
it comes out hence 15
0
Thank you