7.3.08

passing arguments

Passing arguments to function.

Let say
int fun ( int ) ;
is the function prototype.

Now function call was made like this.

fun(x++);

This is not good practice.
In the above call our intension is to pass the incremented value of 'x',
but it pass the value of x not x+1.The best practice is, fun(++x).

Code:

int main()
{
void test_fun(int);
int num=10;
test_fun(num++);
return 0;
}
void test_fun(int num)
{
printf("NUM=%d", num);
}

Output is : NUM=10