• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Switch statement

 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I was reviewing for the exam, and I was wondering if
anyone could be of assistance in explaining the below statement.
An example would probably help. By the way what is a nested case
label and what do the notes mean when they say don't clash with outer case labels.
The switch can be nested. Nested case labels are independent, don�t clash with outer case labels.
Thank you for the help in advance.
 
venkat_alladi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means the following
int c;
switch(c){
case 0: Do something;
case 1:case 2:
switch (c){
case 0: Do something;
case 1: Do something;
}
}
The above switch is nested and inside switch arguement is the same as the one outside and they are independent.
Hope this helps.


------------------
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it means you can have same case labels in nested switch statement. Example
int i = 1;
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that clears it up.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic