0

Hi all, I have a minor confusion regarding the variable accessed
Consider:

int a=5;   //global variable
void increment(int a)
{
  ++a;
}

If I call increment() in main(), which a will be incremented (a passed as a parameter to the function or the global a ?)
Also specify the order of precedence for variables when they need to be accessed. (global,local variable etc)

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by gaurav_13191
0

Seems like the sort of thing that should be testable in a couple of minutes - did you try it?

> Also specify the order of precedence for variables when they need to be accessed.
Again, something that google will easily find 1000's of pages with the operator precedence table.

0

Ok.. I tried the code and got what I expected.. no need to answer.. BTW my second question was something else, but I got its answer too :)

Edited by gaurav_13191: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.