| 1 | // File: fig0629.cpp |
| 2 | // Computer Systems, Fourth Edition |
| 3 | // Figure 6.29 |
| 4 | |
| 5 | #include <iostream> |
| 6 | using namespace std; |
| 7 | |
| 8 | void rect (int& p, int w, int h) { |
| 9 | p = (w + h) * 2; |
| 10 | } |
| 11 | |
| 12 | int main () { |
| 13 | int perim, width, height; |
| 14 | cout << "Enter width: "; |
| 15 | cin >> width; |
| 16 | cout << "Enter height: "; |
| 17 | cin >> height; |
| 18 | rect (perim, width, height); |
| 19 | // ra1 |
| 20 | cout << "perim = " << perim << endl; |
| 21 | return 0; |
| 22 | } |