We know that the C language uses the call by value mechanism to pass parameters and that a function parameter is a copy of the argument specified in the function call.
Thus, a function parameter can be modified without affecting the corresponding argument in the calling function. This fact can often be used effectively to save some memory. Consider function fact given below to determine the factorial of an integer number.
#include <stdio.h>
#include <conio.h>
void main ()
{
int a;
long f,fact();
clrscr();
printf (“\n Enter a Number : “);
scanf (“%d”,&a);
f=fact(a);
printf (“\n The Factorial of %d is : %ld”,a,f);
getch();
}
long int fact(int n)
{
int i;
int fact = 1;
for (i = n; i > 1; i–)
fact *= i;
return fact;
}