home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
353_02
/
answers
/
ch04_3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-19
|
741b
|
32 lines
// Chapter 4 - Programming exercise 3
#include <iostream.h>
#include <stdio.h>
int get_volume(int length, int width = 2, int height);
main()
{
int x = 10, y = 12, z = 15;
cout << "Some box data is " << get_volume(x, y, z) << "\n";
cout << "Some box data is " << get_volume(x, y) << "\n";
cout << "Some box data is " << get_volume(x) << "\n";
cout << "Some box data is " << get_volume(x, 7) << "\n";
cout << "Some box data is " << get_volume(5, 5, 5) << "\n";
}
int get_volume(int length, int width, int height)
{
printf("%4d %4d %4d ", length, width, height);
return length * width * height;
}
// Result of execution
//
// (No result - errors)