Call by Value

Call by value is a value passing mechanism to function in which a value is passed to some function and the function is not responsible for midifying the passed value. If the function modifies any passed values, that value changed locally to the function only. Following example will illustrates the concept.

Example

#include<stdio.h>
// type and declaration of function is defined first if function is 
// other than of integer type
void square(int);  // void type, so declaration is compulsory
int main( ) 
{ 
    int num;
    printf("Enter number ");
    scanf("%d",&num);
    square(num); // calling function square
    printf("number is %d",num); // value of num is not affected
    getchar();
    getchar();    
    return 0;

}
void square(int number)
{
    // value modified locally, no effect to passed value
    number = number + 10;
    printf("local value %d\n",number);
}