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

C Programming Language Function in C Language (Article) Function in C Language (Program)

818

Program:

#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

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.