@srestha mam, in your code there will be a compiler error in the line
int x++; here is an error. So the code will not work.
If the code goes like as shown below:
int func(int x)
{
x++;
return x;
}
Here 4 will be returned to the main().
Or if the code goes like as shown below:
int func(int x)
{
int x;
return x;
}
Here some garbage value will be returned to the main().
Error occurs if within a same scope , a particular variable is declared more than once. Here within the pair of braces in function , which is a scope, x is declared only once. Please dont get confuse with x as a parameter and x as a local variable in the function. The variable x as a function parameter is declared outside the pair of braces i.e. outside the scope where local variable x is declared.
When a function is invoked or called, before entering into the scope of function i.e. before execution of the first instruction of the function starts, the parameter x is declared. Then the control goes into the scope of the function.
In C, same type of variables but different scope or visibility can be declared withot any error.