100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
C++

Function Parameters and Arguments in C++

Learn the difference between function parameters and arguments in C++ and understand pass-by-value semantics with a hands-on example.

FunctionsBeginner7 min readJul 7, 2026
Analogies

1. Intro

Parameters and arguments are related but distinct terms. Parameters are the named variables listed in a function's signature (its declaration/definition) that describe what inputs the function expects. Arguments are the actual values you pass in when you call the function. By default, C++ passes arguments to functions using pass-by-value, meaning the function receives a copy of the data, not the original.

🏏

Cricket analogy: A net session drill plan lists 'batsman, bowler, pitch type' as slots to fill (parameters), while today's actual players like Kohli and Bumrah filling those slots are the arguments; the coach's notes on Kohli don't change the real Kohli.

2. Syntax

cpp
// 'a' and 'b' are PARAMETERS
int add(int a, int b) {
    return a + b;
}

int main() {
    int x = 10, y = 20;
    int sum = add(x, y); // x and y are ARGUMENTS
    return 0;
}

3. Explanation

Think of parameters as placeholders in the function's blueprint, and arguments as the real values plugged into those placeholders at the call site. C++'s default pass-by-value mechanism means that when you call add(x, y), the function add receives its own independent copies of x and y inside its parameters a and b. Any changes made to a or b inside the function body affect only the copy — x and y in main() remain completely unchanged. This is the single most important fact to understand about ordinary C++ parameters: modifying a parameter inside a function does NOT affect the caller's original variable, unless you explicitly use references (&) or pointers (*) to allow the function to modify the original.

🏏

Cricket analogy: When a substitute fielder is handed a photocopy of the field placement chart to mark up during the over, scribbling on it never changes the captain's master chart — exactly like a copied parameter never altering the caller's original variable.

Pass-by-value copy gotcha: because arguments are copied by default, a function like void increment(int n) { n = n + 1; } will NOT change the caller's variable at all. To modify the original, you must pass by reference, e.g. void increment(int &n).

4. Example

cpp
#include <iostream>
using namespace std;

void modifyValue(int num) {   // 'num' is a parameter, receives a COPY
    num = num + 100;
    cout << "Inside function, num = " << num << endl;
}

int main() {
    int original = 5;
    modifyValue(original);   // 'original' is the argument passed
    cout << "Outside function, original = " << original << endl;
    return 0;
}

5. Output

text
Inside function, num = 105
Outside function, original = 5

6. Key Takeaways

  • Parameters are variables named in the function's signature; arguments are the actual values passed at the call site.
  • By default, C++ uses pass-by-value: the function receives a copy of each argument.
  • Changing a parameter inside a function does not affect the caller's original variable.
  • Use reference parameters (&) or pointers to let a function modify the caller's original variable.

Practice what you learned

Was this page helpful?

Topics covered

#CStudyNotes#Programming#FunctionParametersAndArgumentsInC#Function#Parameters#Arguments#Syntax#Functions#StudyNotes#SkillVeris