0
Looping
1. BUG BUSTERS: What is wrong with this code? int counter = 100; while (counter < 10) { cout << “counter now: “ << counter; counter--; } 2. BUG BUSTERS: What is wrong with this code? cout << “Enter a number between 0 and 5: “; cin >> theNumber; switch (theNumber) { case 0: doZero(); case 1: // fall through case 2: // fall through case 3: // fall through case 4: // fall through case 5: doOneToFive(); break; default: doDefault(); break; } please identify the fault in Q1and 2 for me
3 odpowiedzi
+ 2
1. simple loop don't work.
2. case 0 dont break. if 0 make case 0-5
+ 1
first one does not work.
second one is correct but if some one choose case 0 they will also get result from1-5 case. means two result. May be I am wrong.
0
syntactically it is correct.
edit: I don't know what you want to do with this code, so I can't comment. May be some logical error.