Now let's imagine that we need to display different messages in response to a user's error, depending on what kind of mistake he made.
In this case, you can write your own procedure for each error:
void printErrorZero()
{
cout << "Error. Division by zero!";
}
void printErrorInput()
{
cout << "Error in input!";
}
What if there are many more possible errors? This solution will not suit us!
We need to learn how to control the procedure by telling it what error message to display.
To do this, we need parameters that we will write in parentheses after the procedure name
void printError(strings)
{
cout << s;
}
In this procedure, s is a parameter - a special variable that allows you to control the procedure.
The parameter is a variable that determines how the subroutine works. Parameter names are listed separated by commas in the subprogram header. The parameter type is written before the parameter.
Now, when calling the procedure, you need to indicate in brackets the actual value that will be assigned to the parameter (variable s) inside our procedure
printError("Error! Division by zero!");
Such a value is called an argument.
The argument is the parameter value that is passed to the subroutine when it is called.
An argument can be not only a constant value, but also a variable or an arithmetic expression.