Case statement help
I am using this site to teach myself C++ and am doing very well. I am taking notes on everything that I read (hell I even write down the quizes and grade myself). One thing that I don't really understand is the following question:
What is the result of the folowing code:
The answer to the question is: ZeroHello World
case2: cout<<"Hello World";
I just don't understand how the program would come out with this out come. Can anyone help me understand?
Because it starts at x, then goes in ascending order until it reaches a break. for example:
The preceding code would print: ZeroTwo. break's tell the switch statement where to stop, not putting them in makes the statement go to the next number in the list.
case 1: cout<<"One"; break;
case 0: cout<<"Zero";
case 2: cout<<"Two";
EDIT: I shouldn't say number, it goes to the next case in the list, mb
Thank you for clearing that up for me. I really appreciate it.