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?
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.
- so
- since there's no
break;
after it,- the second case executed:
cout<<"hello world";
- the second case executed:
and since cout<<"something";
doesn't add newline after printing, they're printed single word.
Comments
Post a Comment