C program to demonstrate call by value mechanism

      This program explains the mechanism of call by value. In C programming whenever values are passed through function call their values are just copied to formal arguments and the modifications done on formal arguments won’t reflect on main variables. This is illustrated with the help of call by value mechanism.
call by value program in c

Source Code :

int mul_by_10(int num); /* function prototype */
int main(void)
	int result,num = 3;
	printf("\n num = %d before function call.", num);    //Step 1
	result = mul_by_10(num);                             //Step 2         
	printf("\n result = %d after return from function", result);  //Step 3
	printf("\n num = %d", num);   //Step 4
	return 0;

/* function defi nition follows */

int mul_by_10(int num)
	num *= 10;
	return num;


num = 3 before function call.
result = 30 after return from function
num = 3


Step 1: The value of varaiable ‘num’ is printed before function call.

Step 2: The function is called from the main program.

Step 3: The result obtained from the function is printed on the output screen

Step 4: The value of variable ‘num’ is printed after function call.

More Content:Explore More More about Strategies:Strategy