Functions Parameters

A function is given information in the form of a parameter. Within the function, parameters function as variables.

Within the parentheses after the function name, parameters are supplied collectively. The arguments within the parenthesis are separated by commas.

Different parameters have different names.

Formal Parameters

As a result, the variable defined in the function is referred to as a formal parameter or simply a parameter. Variables a and b, for example, are formal parameters.

int sum(int a, int b){
   //function body
}

Actual Parameters

Actual parameters, also referred to as arguments, are the values that are supplied to the function. Examples of arguments include the numbers num1 and num2.

int sum(int a, int b);
 
int main()
{
    int num1 = 5;
    int num2 = 6;
    sum(num1, num2);//actual parameters
}

A function does not need parameters and does not have to return a value.

Shubhajna Rai
Shubhajna Rai

A Civil Engineering Graduate interested to share valuable information with the aspirants.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in