home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / CTUTOR / ANSWERS.ZIP / CH04_3.CPP < prev    next >
C/C++ Source or Header  |  1990-07-20  |  741b  |  32 lines

  1.                               // Chapter 4 - Programming exercise 3
  2. #include "iostream.h"
  3. #include "stdio.h"
  4.  
  5. int get_volume(int length, int width = 2, int height);
  6.  
  7. main()
  8. {
  9. int x = 10, y = 12, z = 15;
  10.  
  11.    cout << "Some box data is " << get_volume(x, y, z) << "\n";
  12.    cout << "Some box data is " << get_volume(x, y) << "\n";
  13.    cout << "Some box data is " << get_volume(x) << "\n";
  14.    cout << "Some box data is " << get_volume(x, 7) << "\n";
  15.    cout << "Some box data is " << get_volume(5, 5, 5) << "\n";
  16.    
  17. }
  18.  
  19. int get_volume(int length, int width, int height)
  20. {
  21.    printf("%4d %4d %4d   ", length, width, height);
  22.    return length * width * height;
  23. }
  24.  
  25.  
  26.  
  27.  
  28. // Result of execution
  29. //
  30. // (No result - errors)
  31.  
  32.