Sams Teach Yourself C++ in 21 Days
int i; //declare outside the for loop for (i = 0; i<5; i++) { std::cout << “i: “ << i << std::endl; } i = 7 ...
More on Program Flow 197 7 25: if (n < 3) 26: return 1; 27: 28: for (n -= 3; n != 0; n--) 29: { 30: minusTwo = minusOne; 31: ...
and think, “two more to do.” You would then add 2+1 and write 3, and think, “one more to find.” Finally, you would write 3+2 and ...
More on Program Flow 199 7 expressionis any legal C++ expression, and the statements are any legal C++ state- ments or block of ...
19: case 1: cout << “Incredible!” << endl; 20: break; 21: default: cout << “Too large!” << endl; 22: bre ...
More on Program Flow 201 7 Using a switchStatement with a Menu ........................................................ Listing ...
202 Day 7 Some programmers like to write: #define EVER ;; for (EVER) { // statements... } NOTE A forever loop is a loop that doe ...
More on Program Flow 203 7 35: default: 36: cout << “Please select again! “ << endl; 37: break; 38: } // end switch ...
: 1 Task One! **** Menu **** (1) Choice one. (2) Choice two. (3) Choice three. (4) Redisplay menu. (5) Quit. : 3 Task Three! *** ...
More on Program Flow 205 7 Summary ............................................................................................. ...
better—and more in line with the current standards—to use an expression that evaluates to a Boolean value of true or false. Howe ...
More on Program Flow 207 7 7.BUG BUSTERS:What is wrong with this code? int counter = 100; while (counter < 10) { cout << ...
...
In Review You have finished your first week of learning how to program in C++. You should feel comfortable entering programs and ...
210 Week 1 LISTINGR1.1 Week 1 in Review Listing 1: /* Listing: WR01.cpp 2: * Description: Week in Review listing for week 1 3: * ...
In Review 211 31: private: 32: int itsWidth; 33: int itsHeight; 34: }; 35: 36: // Class method implementations 37: void Rectangl ...
212 Week 1 65: while (!fQuit) 66: { 67: choice = DoMenu(); 68: if (choice < DrawRect || choice > Quit) 69: { 70: cout < ...
In Review 213 93: break; 94: case Quit: 95: fQuit = true; 96: cout << “\nExiting... “ << endl << endl; 97: bre ...
214 Week 1 124: int height = theRect.GetHeight(); 125: int width = theRect.GetWidth(); 126: 127: for (int i = 0; i<height; i+ ...
In Review 215 *** Menu *** (1) Draw Rectangle (2) Area (3) Perimeter (4) Resize (5) Quit 2 Area: 150 *** Menu *** (1) Draw Recta ...
«
7
8
9
10
11
12
13
14
15
16
»
Free download pdf