C++语言程序设计

| 例5-7

#include<iostream.h> //C++库函数说明
int area(int length, int width); // area函数说明
void main() //主函数，程序从该函数开始执行
{
int this_length, this_width;
cout << "Enter the length: "; //调用cout和cin库函数
cin >> this_length;
cout << "Enter the width: ";
cin >> this_width;
cout << "\n";
cout << "The area of a " << this_length << "x" << this_width;
cout << " rectangle is " << area(this_length, this_width); //调用area函数
}
int area(int length, int width) // area函数定义
{
int number;
number = length * width;
return number;
}