title: How do i delete/insert an element of an array in C++
body: <p>So first question, i have this array here:</p>
  
  <pre><code>arr[] = {1; 2; 3; 4; 5}
  </code></pre>
  
  <p>and if i type in for example: 3
  the third element will be deleted and replaced by the next value.
  like this:</p>
  
  <pre><code>arr[] = {1; 2; 4; 5}
  </code></pre>
  
  <p>i have got this code here:</p>
  
  <pre><code>for(int i = 2; i &lt; n; i++)
  {
      arr[i] = arr[i + 1];
      arr[n - 1] = 0;
  }
  </code></pre>
  
  <p>but the outcome is</p>
  
  <pre><code>arr[] = {1; 2; 4; 0; 0}
  </code></pre>
  
  <p>please fix the code</p>
  
  <p>second question,
  i will type in "3" as well but instead of delete the third element and replace it, i have to insert a new third element i.e "50" so that:</p>
  
  <pre><code>arr[] = {1; 2; 3; 4; 5}
  </code></pre>
  
  <p>will become:</p>
  
  <pre><code>arr[] = {1; 2; 50; 3; 4; 5}
  </code></pre>
  
  <p>I'm still a noob at programming and C++ and this is my first question so please answer nicely :D</p>
  
  <p>Thanks alot</p>