Quantcast
Channel: switch-case statement without break - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by soch guru for switch-case statement without break

$
0
0

The key is execution control is transferred to the statement for the matching case. E.g.

1. switch(x) {
2.   case 1:
3.      do_step1;
4.   case 2:
5.      do_step2;
6.   default:
7.      do_default;
8.   }

Treat lines 2, 4, 6, as "Labels" for the goto calls. On x = 1, the control will be transferred to line 3 & execution of line 3, 5 & 7 will occur.


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>