Sams Teach Yourself C++ in 21 Days

(singke) #1
More on Program Flow 207

7


7.BUG BUSTERS:What is wrong with this code?
int counter = 100;
while (counter < 10)
{
cout << “counter now: “ << counter;
counter--;
}


8.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;
}
Free download pdf