ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

LANGUAGE C

Calling The Function by Value

  Call by Value

     In C, by default, all function arguments are passed by value.This means that when arguments are passed to the called function, the values passed are through temporary variables. Any manipulation to be done is done only on these temporary variables. The called function cannot access the actual memory location of the original variable and therefore cannot change its value. 

#include <stdio.h> 
main ( )
{
int a, b, c; 
a = b = c = 0;
printf("\nEnter ist integer . "); 
scanf ( "%d", &a) ;
printf("\nEnter 2nd integer . "); 
scanf ("%d", &b) ;
c = adder (a, b) ;
printf ("\n\na & b in main () are . %d,% d", a, b);
printf ("\n\nC IS . %d", C) ;
}
adder(int a, int b) 
{
int c;
c = a + b; 
a *= a;
b += 5;
printf("\n\na & b within adder function are: %d, %d ", a, b) ; printf("\nc within adder function is .%d", c) ;
return(c);
}

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here