Functions in C language can be called by two methods:
  1. Call by value
  2. Call by reference
Call by value:

Call by value basically means passing values between functions when they are called i.e. user provides values to the functions when they are called in the MAIN() function.THese values can either be any constants or variables.
An example illustrating this is given below:

/* Sending and receiving values between functions */

main( )
{
int m, n, p, sum ;
printf ( "\nEnter any three numbers " ) ;
scanf ( "%d %d %d", &m, &n, &p ) ;
sum = calsum ( m, n, p ) ;
printf ( "\nSum = %d", sum ) ;
}
calsum ( a, b, c )
int a, b, c ;
{
int s ;
s = a + b + c ;
return ( s ) ;
}

Output:
Enter any three numbers 11 12 13
Sum = 36




0 comments to "CALLING FUNCTIONS IN C LANGUAGE"

Post a Comment

Powered by Blogger.