May 2002
Beginner
320 pages
6h 18m
English
The program is getting a bit long by now. Even with the use of exception handling to reduce the amount of error code, it is getting a little hard to follow. So you can split it into functions, each of which is a smaller and more understandable piece of largely self-contained code with a name that indicates its purpose. Listing 7.1 shows what the program looks like when you do this.
1: #include <iostream> 2: 3: using namespace std; 4: 5: void Initialize(void) // No return value, no arguments 6: { 7: cin.exceptions(cin.failbit); 8: } 9: 10: float GetDividend(void) // Returns dividend, a float 11: { 12: float Dividend = 0; 13: 14: cout << "Dividend: "; 15: cin >> Dividend; ... |
Read now
Unlock full access