CParameters & Arguments

Parameters & Arguments

The words "parameter" and "argument" are often used interchangeably in casual conversation, but they refer to two different things. Knowing the difference makes it much easier to read compiler messages and documentation precisely.

Parameters vs Arguments
  • Parameter — a variable listed in the function's definition (or declaration) that describes what kind of input the function expects.

  • Argument — the actual value you supply for a parameter at a specific call site.

Parameters vs arguments

C
#include <stdio.h>

// 'a' and 'b' are PARAMETERS: names + types describing expected input
int multiply(int a, int b) {
    return a * b;
}

int main(void) {
    int x = 6, y = 7;

    // 6 and 7 (or x and y) are the ARGUMENTS: actual values supplied here
    int result = multiply(x, y);

    printf("%d\n", result);
    return 0;
}

Each call can pass different arguments, but the parameter names and types stay fixed by the function's definition.

Multiple Parameters

A function can take as many parameters as you need, separated by commas. Each one needs its own type, even if several parameters share the same type.

A function with several parameters

C
#include <stdio.h>

double average3(double a, double b, double c) {
    return (a + b + c) / 3.0;
}

int main(void) {
    printf("Average: %.2f\n", average3(4.0, 8.5, 6.0));
    return 0;
}
Everything in C Is Passed by Value

This is one of the most important facts about C functions: every argument is copied into its parameter when a function is called. The function works with its own local copy; the original value at the call site is never touched directly.

Modifying a parameter does not affect the caller

C
#include <stdio.h>

void increment(int n) {
    n = n + 1; // only changes the local copy
}

int main(void) {
    int x = 10;
    increment(x);
    printf("%d\n", x); // still prints 10
    return 0;
}
Pointers are copied too
A very common point of confusion: even when you pass a *pointer* as an argument, the pointer itself is passed by value — the pointer variable is copied, not shared. What this buys you is that the copied pointer still points to the *same* memory address as the original, so the function can follow that pointer to reach and modify the original data. But if you reassign the parameter itself to point somewhere else, that change is local and the caller's pointer is unaffected. We'll unpack this carefully in the upcoming pages on pass-by-value and pass-by-reference.
Prototypes Enable Type Checking

Because a prototype specifies the exact type of each parameter, the compiler can check every call site against it and catch mismatches before your program ever runs.

The compiler catches parameter mismatches

C
#include <stdio.h>

int square(int n); // prototype: expects exactly one int

int main(void) {
    printf("%d\n", square(5));       // OK
    printf("%d\n", square(5, 10));   // compiler error: too many arguments
    printf("%d\n", square("five"));  // compiler warning/error: wrong type
    return 0;
}

int square(int n) {
    return n * n;
}

Term

Where it lives

Example

Parameter

In the function's signature

int a in int add(int a, int b)

Argument

At the call site

5 in add(5, 3)

Parameter names are just labels
Inside the function body, a parameter behaves exactly like a local variable initialized with the argument's value. Its name only matters within that function — the caller never needs to know what the parameters are called, only their types and order.
Next up
The following pages dedicate full attention to return values, and then to the pass-by-value model in detail — including the classic broken `swap` example and how pointers fix it.