Parameter vs. argument

Beginner programmers often find themselves interchangeably using the terms parameter and argument. However, these two terms are not the same. Luckily, it’s not hard to wrap your head around the differences.

A parameter is a variable in a function definition. It is a placeholder and hence does not have a concrete value.

An argument is a value passed during function invocation.

In a way, arguments fill in the place the parameters have held for them.

The diagram below shows the differences clearly:

Let’s look at arguments and parameters one by one in different programming languages like Python, C++, and Java. The code below shows a simple function called introduction, which prints the name and age of a person:

  • In Python:

# Here name and age are parameters of the introduction function
def introduction(name, age):
print("Hello! My name is {} and I am {} years old.".format(name, age))
# Here Jerry and 15 are arguments passed to the introduction function
introduction("Jerry", 15)
  • In C++:

#include <iostream>
using namespace std;
// Here name and age are parameters of the introduction function
void introduction(string name, int age){
cout << "Hello! My name is " << name << " and I am " << age <<" years old."<< endl;
}
int main() {
// Here Jerry and 15 are arguments passed to the introduction function
introduction("Jerry", 15);
return 0;
}
  • In Java:

class Hello {
// Here name and age are parameters of the introduction function
public static void introduction(String name, int age)
{
System.out.println(String.format("Hello! My name is %s and I am %d years old.", name, age));
}
public static void main( String args[] ) {
// Here Jerry and 15 are arguments passed to the introduction function
introduction("Jerry", 15);
}
}