# 7.1 — Function parameters and arguments

In Chapter 1, we covered function basics in the following sections:

You should be familiar with the concepts discussed in those lessons before proceeding.

Parameters vs Arguments

Up until now, we have not differentiated between function parameters and arguments. In common usage, the terms parameter and argument are often interchanged. However, for the purposes of further discussion, we will make a distinction between the two:

A function parameter is a variable declared in the prototype or declaration of a function:

An argument is the value that is passed to the function in place of a parameter:

When a function is called, all of the parameters of the function are created as variables, and the value of the arguments are copied into the parameters. For example:

When foo() is called with arguments 6 and 7, foo’s parameter x is created and assigned the value of 6, and foo’s parameter y is created and assigned the value of 7.

Even though parameters are not declared inside the function block, function parameters have local scope. This means that they are created when the function is invoked, and are destroyed when the function block terminates:

There are 3 primary methods of passing arguments to functions: pass by value, pass by reference, and pass by address. The following sections will address each of those cases individually.

 7.2 -- Passing arguments by value Index 6.15 -- An introduction to std::array

### 18 comments to 7.1 — Function parameters and arguments

• moon1212

pls… help me

• Mallinath

are you asking the full code here…. i better suggest try it your own …
if any problem you can paste the code guys will help you out.

• moon1212

Q.1 write a the c program using a function method to calculation the area and perimeter for the rectangle and the square by any given width and height . the program should ask the user to stop or retry the program with other values .

Q.2 write a program in c language using a function method to calculate the following series and give the result;
X= n^1*n^2*n^3*…………* n^k
Where n&k are any number given by the user

pls... help me

• chesslover

Thanks for the lessons!
They are amazingly well explained!
Congratulations!

• ender

This helped thanks

• bla

"When a function is called, all of the parameters of the function are created as variables, and the value of the arguments are copied into the parameters."

The last bit of this sentence sounds awkward. Shouldn't it be: "... copied into the variables."?

• THE TERMINATOR

Seeing as the paremeters are the variables anyway, it does that already, it's just implied :).

• koorosh

what are actual argument(actual parameter) and formal argument(formal parameter)?!
they use in some books!
what difference between argument and parameter?

• THE TERMINATOR

Think of it like this: an argument is the giver and the paremeter is the reciever.

• Shriram M

Actual parameters are nothing but the actual values/arguments you are passing during function call[ex: foo(6,7);].
Formal parameters are the parameters into function definition [ex: int foo(int i, int j)]

• ross

i dont understand about the calling a function..anybody can help me...

• Kiena

Since terms are discussed, isn't the prototype in fact the function declaration, and the declaration including the body the definition? Correct me, if I'm mistaken.

• Manoj Kumar Ray

i want to know How to pass the HTML Tags as a parameter to the C++ Function and want to store the result in a XML Buffer.

• Tom

Alex -

If, by definition, "An argument is the value that is passed to the function", then shouldn't the last sentence of this lesson have started:

"There are 3 primary methods of passing arguments to functions:"?

[ Yep. Fixed. -Alex ]