This lesson explains how the parameters passed in the main function are assigned and used in the function itself using an example.

We'll cover the following

Parameters Syntax

Parameters are how data is passed between functions through the call of the function.

We learned earlier that we list the data we want to pass to a function in the call between the ( ). The order of the list is determined by the function definition. The first parameter in the list will be assigned to the variable listed first in the function definition.

Note: In most cases, you must have the correct number and type of data being passed to the function or you will receive an error when you try to compile your program.


Let’s take a look at an example below:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy