1] Local variable:
▪️ A variable that is declared within the function , it is called local variable.
▪️ The scope of local variable can be accessible only from within the function in which it is declared.
▪️ Local variable can accessible only from within the function in which it is declared.
2] Global variable:
▪️ A variable that is declared outside of all the functions, it is called global variable.
▪️ The scope of variable is whole the program. In other words, it can be used in any function of the program.
▪️ Global variable can be accessible from all the function of the program.
3] calling function:
▪️ A function that has a statement to call another function, is called calling function.
▪️ Control of program is transferred to the call function,after executing all it's statements, the program control is sent back to the calling function.
4] called function:
▪️ Function that has been called from another function is known as called function.
▪️ program control is transferred from the calling function to the called function, after executing all it's statements, the control is sent back to the calling function.
5] Actual argument:
▪️ When we pass argument at the time of calling of function, these arguments are known as actual arguments.
▪️ Values of actual argument at the copied in to formal arguments.
▪️ We can also transfer the address of actual arguments to the format arguments,if the formal arguments are pointer variable.
6] Formal argument:
▪️ The arguments that will collect the values/addresses of actual arguments are called formal arguments.
▪️ Formal arguments are defined within the function defination, in function header.
▪️ There should be match the actual and formal arguments in number, type,and sequence.
▪️ consider the following example:
#include<stdio.h>
void display(int);
int p;
void main( )
{
int a = 15;
p = 10;
printf("Global variable = %d",p);
printf("Local variable = %d",a);
p = 20;
display(a);
}
void display (int x)
{
int y = 100;
printf("Global variable=%d,p);
printf("Formal argument of display=%d",x)
printf(Local variable of display=%d",y);
}
Output:
Global variable=10
Local variable of main=15
Global variable=20
Formal argument of display=15
Local variable of display=100
nice
ReplyDelete