Home / Programs / Write C a program that uses a function show call by value mechanism.
Programming Example

Write C a program that uses a function show call by value mechanism.

👁 911 Views
💻 Practical Program
📘 Step by Step Learning
Write C a program that uses a function show call by value mechanism.

Program Code

#include <stdio.h>

int mul_by_10(int num); /* function prototype */

int main(void)
{
	int result,num = 3;
	printf("\n num = %d before function call.", num);
	result = mul_by_10(num);
	printf("\n result = %d after return from function", result);
	printf("\n num = %d", num);
	return 0;
}

/* function defi nition follows */

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

Output


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

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.