**Parameters** are variables defined in the function's declaration that receive values when the function is called. These values are known as **Arguments**. By using parameters, you can create flexible code that can handle various inputs without changing the internal logic of the function.
While the terms are often used interchangeably, there is a technical difference that every professional C programmer should know:
int x). Think of them as the containers.10). Think of them as the content.You can pass as many parameters as you need, separated by commas. However, when calling the function, the number and order of arguments must match the parameters exactly.
By default, C uses a method called **Pass by Value**. This means the function receives a copy of the data. If you change the parameter's value inside the function, the original variable in the main() function remains unchanged.
If you want a function to modify the original variable, you must pass the memory address (using pointers). This is known as **Pass by Reference**. It is highly efficient because it avoids copying large amounts of data.
When you pass an array to a function, C does not copy the entire array. Instead, it passes a pointer to the first element. This is why changes to an array inside a function will affect the original array.
| Feature | Pass by Value | Pass by Reference |
|---|---|---|
| What is passed? | Copy of data | Memory address |
| Original variable | Protected/Unchanged | Can be modified |
| Memory usage | Higher for large data | Lower (very efficient) |
const keyword in the parameter: void printMsg(const char str[]).