Define the following terms : a) Actual parameters b) Formal parameters c) Global variables d) Local variables.

Actual parameters :  When a function is called from main program(calling function), the function call contains a list of data(variables) that are sent as input to the called function. Such data are called as actual parameters or actual arguments.
Example : x = test(p,q,r); where p,q,r are actual arguments

Formal parameters : The function header of a called function contains a list of data along with their data types. This list of data are known as formal parameters. The formal parameters receive their value from actual parameters.

a. The formal parameter values are available only as long as the function is being executed.
b. For every actual argument there must be a formal argument of the same data type.
c. Any changes made to the formal parameters in the called function do not change the actual parametersOnce the function is terminated the formal parameters are not available any more.
Example : int prod(int m, int n); //function header

Local variables : Local variables are the data declared within a user defined function and available only within that function.
Example :
int sum(int x, int y)
{
int r;
………
………
}

Global variables :  Global variables are the data that are declared before the main program and that are available to the main program as well as the functions that are called from the main program.

int p, r;
void main()
{
………
………
}


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: