Yes, this is called the scope of the variable and is limited by the block within which it's declared. Blocks are delimited by braces { } and/or function/method definitions. If something is declared within a block, that's called local scope, and outside of any block is global scope.
As you suspected, this means that if a variable is declared with the same name in more than one block, all instances of that variable are separate.
Also keep in mind that local scope has priority over global scope, and nested blocks have priority over outer blocks.
So, with reference to tfityo's example
1. Within the while loop, referencing i will use the int i declared at line 7, not the one at line 2 (the while loop is a nested block).
2. Outside of the while loop, and within function f1(), the int i declared at line 7 is out of scope (not defined), so the one from line 2 is used.