C++ Switch Cases -


i doing quiz online based on c++ switch statement. came across question , have fair understanding of how switch statements work 1 question made absolutely no sense me. can please explain?

screenshot!

why answer d , not c? case 2: default case or what? quiz can found at: http://www.cprogramming.com/tutorial/quiz/quiz5.html

here's how code behaves.

  • x equal 0
    • so cout<<"zero"; executed.
  • since there's no break; after it,
    • the second case executed: cout<<"hello world";

and since cout<<"something"; doesn't add newline after printing, they're printed single word.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -