new operator allocates more size than declared . WHY : <p>I am using codeblocks 16.01. And here in the code given below I have used   new operator and declared array - pointer .</p>

<pre><code>#include &lt;iostream&gt; 
using namespace std;
int main()
{
 int *p = new int[2];
 for(int i=0; i&lt;10;i++)
 {   
     cout&lt;&lt;"\n Enter the element  "&lt;&lt;i &lt;&lt; " :  ";
     cin&gt;&gt;*(p+i);
 }
 for(int i=0; i&lt;10;i++)
   cout&lt;&lt;"\n"&lt;&lt;*(p+i)&lt;&lt;" :  "&lt;&lt; i &lt;&lt; "th element ";
 }
</code></pre>

<p>Here is the image why i have doubt<a href="https://i.stack.imgur.com/WilsX.png" rel="nofollow noreferrer">the size declared is 2 but the array is able to store for 7 elements also why is this happening ??. Even I tried to increase the size to 5 then also it took and stored 7 elements value but rest it gave the address. Why ? </a> </p>
