Function parameters let you send information into a function so it can use that information to do its job.
Function parameters
return_type function_name(type1 param1, type2 param2, ...) {
// function body
}Parameters are listed inside the parentheses after the function name.
Each parameter has a type and a name, separated by a space.
void greet(char name[]) { printf("Hello, %s!\n", name); }
int add(int a, int b) { return a + b; }
void printNumber(int number) { printf("Number: %d\n", number); }
This program defines a function add that takes two numbers and returns their sum. In main, it calls add with 5 and 7 and prints the result.
#include <stdio.h> // Function that adds two numbers and returns the result int add(int x, int y) { return x + y; } int main() { int result = add(5, 7); printf("The sum of 5 and 7 is %d\n", result); return 0; }
Parameters act like placeholders for the values you give when calling the function.
The names of parameters are local to the function and can be different from argument names.
If you don't provide the right number or type of arguments when calling, the program may not work correctly.
Function parameters let you send data into functions to work with.
They are defined by type and name inside the parentheses after the function name.
Using parameters makes your functions flexible and reusable.