Course Content
C++ Introduction
C++ Introduction
4. Introduction to Program Flow
5. Introduction to Functions
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
You can pass multiple arguments to a function:
main
func(5, 7)
– calling a function and passing arguments to it.
Arguments are passed with commas (,
). You can also pass arrays:
main
Everything was clear?