home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tutorial / cpptutor / source / default.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-15  |  952 b   |  37 lines

  1.                                // Chapter 4 - Program 4 - DEFAULT.CPP
  2. #include <iostream.h>
  3. #include <stdio.h>
  4.  
  5. int get_volume(int length, int width = 2, int height = 3);
  6.  
  7. void 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.  
  15.    cout << "Some box data is ";
  16.    cout << get_volume(x, 7) << "\n";
  17.    cout << "Some box data is ";
  18.    cout << get_volume(5, 5, 5) << "\n";
  19. }
  20.  
  21. int get_volume(int length, int width, int height)
  22. {
  23.    printf("%4d %4d %4d   ", length, width, height);
  24.    return length * width * height;
  25. }
  26.  
  27.  
  28.  
  29.  
  30. // Result of execution
  31. //
  32. //   10   12   15Some box data is   1800
  33. //   10   12    3Some box data is    360
  34. //   10    2    3Some box data is     60
  35. // Some box data is   10    7    3   210
  36. // Some box data is    5    5    5   125
  37.