Function arguments:
- Arguments of function working like local variables.
- Local variables can access only from the same function.
#include<stdio.h>
void fun(int);
int main()
{
int x=2;
fun(x);
printf("x value is : %d \n", x);
return 0;
}
void fun(int x)
{
++x;
}
Output this code:
#include<stdio.h>
void fun(int);
int main()
{
int x=2;
fun(x++);
printf("x value is : %d \n", ++x);
return 0;
}
void fun(int y)
{
printf("y value : %d \n", y++);
}
In function call, all arguments execute from right to left
#include<stdio.h>
void fun(int, int, int);
int main()
{
int x=2;
fun(++x, ++x, ++x);
return 0;
}
void fun(int x, int y, int z)
{
printf("x value : %d \n", x);
printf("y value : %d \n", y);
printf("z value : %d \n", z);
}
Output this code:
#include<stdio.h>
void fun(int, int, int);
int main()
{
int x=5;
fun(++x, x++, x--);
fun(--x, x--, ++x);
return 0;
}
void fun(int x, int y, int z)
{
printf("%d, %d, %d\n", x, y, z);
}
Crack this code:
#include<stdio.h>
void fun(int, int);
int main()
{
int x=5;
fun(++x, x--);
fun(--x, x++);
printf("%d \n", x++);
return 0;
}
void fun(int x, int y)
{
printf("%d, %d\n", x, y);
}