Function Parameters In C
- A function in all programming languages. A function is a group of statements clubbed together to perform a particular task.
- Each function is accompanied by a set of parenthesis, the opening bracket ( and the closing bracket ). There may be a group of variable declarations called parameters inside these parenthesis.
- Parameter is a variable that is used to pass values or pointers to a function. A function can have zero or more parameters, which are defined in the function declaration.
Syntax:
returnType functionName(parameter1, parameter2, parameter3) {
// code to be executed
}
// code to be executed
}
Types Of Functions
- User defined functions
- Built-in functions
Program:
#include <stdio.h>
void multiply(int a, int b){
int result = a * b;
printf("The result of %d * %d is %d\n", a, b, result);
}
int main(){
int x = 5;
int y = 4;
multiply(x, y); // Call multiply function with arguments x and y
return 0;
}
void multiply(int a, int b){
int result = a * b;
printf("The result of %d * %d is %d\n", a, b, result);
}
int main(){
int x = 5;
int y = 4;
multiply(x, y); // Call multiply function with arguments x and y
return 0;
}
Output:
The result of 5 * 4 is 20
More topic in C