Function Parameters in C

Last Updated : 1 Jul, 2026

Function parameters (or arguments) are the values passed to a function from the calling function. They provide input data that the function uses to perform a specific task.

  • Parameters allow a function to work with different input values.
  • They make functions reusable and flexible.
C
#include <stdio.h>

void add(int a, int b)
{
    printf("Sum = %d", a + b);
}

int main()
{
    add(10, 20);
    return 0;
}

Output
Sum = 30

Syntax

Function parameters must be specified in the function definition inside the parenthesis as shown:

// Single parameter
returnType name (parameter_type parameter_name) {
...
}

// Multiple parameters
rType name (p1_type p1_name, p2_type p2_name, .......) {
...
}

Here, the variables declared inside () are placeholders. They are not the actual values but instead variables that will be assigned the value that is received. They are also called formal arguments or simply parameters.

After parameters are defined in the function definition, we have to pass the exact same number of values in the function call. The values passed here are called actual arguments or simply arguments.

// Passing single argument
function_name(value/variable);

// Passing multiple argument
function_name(val1, val2, val3, ....);

The type and the sequence of the passed values should be same as in the function definition, otherwise, an error may occur.

function-parameters-and-arguments

Let's take another example in which we pass multiple values:

C
#include <stdio.h>

// Function definition with multiple
// parameters
int sum(int a, int b) {
    return a + b;
}

int main() {
    int num1 = 20, num2 = 10;
    
    // Calling function and passing
    // argument
    int res = sum(num1, num2);
    printf("%d + %d = %d", num1, num2, res);
    return 0;
}

Output
20 + 10 = 30

Parameters Passing Techniques

In C, there are 2 ways in which we can pass parameters:

  1. Pass by Value
  2. Pass by Pointer

In all the above examples, we have used pass by value method in which the copy of the value of the variable is created in the function. On the other hand, in pass by pointer method, we pass the address of the argument instead of the copy.

C
#include <stdio.h>

// Passing a by value and b by pointer
void change(int a, int* b) {
    a = 99;
    *b = 99;
}

int main() {
    int num1 = 20, num2 = 10;
    
    // Passing num1 normally but passing
    // num2's address
    change(num1, &num2);
    
    printf("%d + %d", num1, num2);
    return 0;
}

Output
20 + 99

As we can see, only the value of num2 is changed which was passed by pointer instead of normal pass by value. This concept requires the knowledge of pointers in C. Refer to this article to know more - Parameter Passing Techniques in C

Difference Between Pass by Value and Pass by Pointer

Pass by ValuePass by Pointer
A copy of the variable's value is passed to the function.The address of the variable is passed to the function.
Changes made inside the function do not affect the original variable.Changes made inside the function do affect the original variable.
The function works on a separate copy of the data.The function works on the original data through its address.
Does not require pointers.Requires pointers.
Suitable when the original data should remain unchanged.Suitable when the function needs to modify the original data or avoid copying large objects.
Comment