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)

Recommended Answers

All 2 Replies

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.

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.