Variable declaration in c++
<p>when i run the following c++ code</p>

<pre><code>#include&lt;iostream&gt;

int main()
{
   for(int i=1;i&lt;=10;i++)
   {
       cout&lt;&lt;i&lt;&lt;endl;
   }
   cout&lt;&lt;i;

   getch();
   return 0;
}
</code></pre>

<p>I get result from no. 1 to 11.</p>

<p>i don't understand why the value of i = 11 after the block of for loop is finished,Please give me the reason.I have declared i inside for loop and scope of i has been finished after loop so why i get the outpout i=11 after execute second cout statement .I have not declared i in the variable declaration inside main.My question is that is i is visible outside of for loop?
Thanks in advance.</p>
