Functions With Arguments
A function with a parameter (argument) is a function that has to work with an object from the outside the function.
Note
A function argument is a local variable created and exists only in the current function.
For example, let's create a function that divides any integer by 2:
To use such a function, you need to call it and pass an argument to it:
Here is an example:
main.cpp
You can pass multiple arguments to a function:
main.cpp
func(5, 7)
– calling a function and passing arguments to it.
Arguments are passed with commas (,
). You can also pass arrays:
main.cpp
¿Todo estuvo claro?
Contenido del Curso
C++ Introduction
4. Introduction to Program Flow
5. Introduction to Functions
C++ Introduction
Functions With Arguments
A function with a parameter (argument) is a function that has to work with an object from the outside the function.
Note
A function argument is a local variable created and exists only in the current function.
For example, let's create a function that divides any integer by 2:
To use such a function, you need to call it and pass an argument to it:
Here is an example:
main.cpp
You can pass multiple arguments to a function:
main.cpp
func(5, 7)
– calling a function and passing arguments to it.
Arguments are passed with commas (,
). You can also pass arrays:
main.cpp
¿Todo estuvo claro?