Function
A function has the following form:
type name (parameter_1, parameter_2, parameter_...){
// code to execute inside function
}
For example:
#include <iostream>
using namespace std;
void box(int length, int width, int height);
int main()//main function
{
box(30, 20, 5);//call function "box"
return 0;
}
//here is function "box"
void box(int length, int width, int height)
{
cout << "volume of box is " << length * width * height
<< "\n";
} |