Course contentsShow
← C
Lesson 335 of 1,2195. FunctionsFree lesson

Parameters vs. Arguments

Parameters vs. Arguments

What you'll learn: How to distinguish between the placeholders defined in a function and the actual values you pass into them.

The Recipe Analogy

Imagine you have a recipe for a "Fruit Smoothie." The recipe says you need [Fruit] and [Liquid]. In the world of C, these labels are your Parameters. They are empty slots or "placeholders" that define what type of data a function expects to receive.

Now, imagine you actually go into the kitchen to make the smoothie. You grab a Banana and some Milk. These specific items are your Arguments. They are the real, concrete values you "pass" into the recipe to get a result.

Parameters: The Placeholders

When you define a function, you list its parameters inside the parentheses. You must give them a type (like int or float) and a name. These variables only exist inside the function's curly braces.

// 'a' and 'b' are the PARAMETERS
// They act as containers waiting to be filled.
void add_numbers(int a, int b) {
    int sum = a + b;
    printf("The total is %d", sum);
}

Arguments: The Real Values

When you actually call (use) the function in your code, you provide arguments. These are the specific pieces of data you want the function to process.

int main() {
    // 5 and 10 are the ARGUMENTS
    // They are copied into the parameters 'a' and 'b'.
    add_numbers(5, 10);

    int x = 20;
    int y = 30;
    
    // x and y are also ARGUMENTS here
    add_numbers(x, y);

    return 0;
}

How they work together

Think of the Parameter as a parking spot and the Argument as the car. The parking spot is part of the layout (the function definition), but it stays empty until a car (the data) actually drives in during the function call. In C, when you pass an argument, the program makes a copy of that value and hands it to the parameter.

Key takeaway

Parameters are the variables listed in the function's definition; arguments are the actual values you pass to the function when you call it.