C Function with arguments and with return value
In C, this type of function can accept input using argument and also return a value. Arguments and return type of such functions can be of any valid c data types.
Function Declaration Syntax
<return_type> <function_name>(parameter1, parameter2);
Function Definition Syntax
<return_type> <function_name>(parameter1, parameter2)
{
// set of statements
return variable_name;
}
Function call Syntax
<function_name>(parameter1, parameter2);
Example
#include<stdio.h>
//Function Declaration
float MultiplyNumbers(int, float);
void main()
{
int a = 5;
float b = 20.10, c = 0;
c = MultiplyNumbers(a,b); //Function call
printf("%f", c);
}
//Function Definition
float MultiplyNumbers(int a, int b)
{
float c = 0;
c = a * b;
return c; // Returning value
}