Difference between Argument and Parameter in C/C++ with Examples - GeeksforGeeks

24 Jun, 2021
Argument
An argument is referred to the values that are passed within a function when the function is called. These values are generally the source of the function that require the arguments during the process of execution. These values are assigned to the variables in the definition of the function that is called. The type of the values passed in the function is the same as that of the variables defined in the function definition. These are also called Actual arguments or Actual Parameters.
Example: Suppose a sum() function is needed to be called with two numbers to add. These two numbers are referred to as the arguments and are passed to the sum() when it called from somewhere else.
C
C++
// C code to illustrate Arguments #include <stdio.h> // sum: Function definitionint sum(int a, int b){    // returning the addition    return a + b;} // Driver codeint main(){    int num1 = 10, num2 = 20, res;     // sum() is called with    // num1 & num2 as ARGUMENTS.    res = sum(num1, num2);     // Displaying the result    printf("The summation is %d", res);    return 0;}
// C++ code to illustrate Arguments#include <iostream>using namespace std; // sum: Function definitionint sum(int a, int b){    // returning the addition    return a + b;} // Driver codeint main(){    int num1 = 10, num2 = 20, res;     // sum() is called with    // num1 & num2 as ARGUMENTS.    res = sum(num1, num2);     // Displaying the result    cout << "The summation is " << res;    return 0;}
The summation is 30

Parameters
The parameter is referred to as the variables that are defined during a function declaration or definition. These variables are used to receive the arguments that are passed during a function call. These parameters within the function prototype are used during the execution of the function for which it is defined. These are also called Formal arguments or Formal Parameters.Example: Suppose a Mult() function is needed to be defined to multiply two numbers. These two numbers are referred to as the parameters and are defined while defining the function Mult().
C
C++
// C code to illustrate Parameters #include <stdio.h> // Mult: Function definition// a and b are the PARAMETERSint Mult(int a, int b){    // returning the multiplication    return a * b;} // Driver codeint main(){    int num1 = 10, num2 = 20, res;     // Mult() is called with    // num1 & num2 as ARGUMENTS.    res = Mult(num1, num2);     // Displaying the result    printf("The multiplication is %d", res);    return 0;}
// C++ code to illustrate Parameters #include <iostream>using namespace std; // Mult: Function definition// a and b are the parametersint Mult(int a, int b){    // returning the multiplication    return a * b;} // Driver codeint main(){    int num1 = 10, num2 = 20, res;     // Mult() is called with    // num1 & num2 as ARGUMENTS.    res = Mult(num1, num2);     // Displaying the result    cout << "The multiplication is " << res;    return 0;}
The multiplication is 200

Difference between Argument and Parameter
int num = 20;Call(num)     // num is argument
int Call(int rnum){    printf("the num is %d", rnum);} // rnum is parameter
sagar0719kumar
C Language
C++
Difference Between
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
'this' pointer in C++
Exception Handling in C++
Multithreading in C
UDP Server-Client implementation in C
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
Socket Programming in C/C++