declarefunction.cpp
来自「《24学时精通c++》的光盘内容」· C++ 代码 · 共 28 行
CPP
28 行
// Listing 5.1 - demonstrates the use of function prototypes
#include <iostream>
int FindArea(int length, int width); //function prototype (declaration)
int main()
{
int lengthOfYard;
int widthOfYard;
int areaOfYard;
std::cout << "\nHow wide is your yard? ";
std::cin >> widthOfYard;
std::cout << "\nHow long is your yard? ";
std::cin >> lengthOfYard;
areaOfYard= FindArea(lengthOfYard,widthOfYard);
std::cout << "\nYour yard is ";
std::cout << areaOfYard;
std::cout << " square feet\n\n";
return 0;
}
int FindArea(int l, int w) // function definition
{
return l * w;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?