title: Inserting an element into an array
body: <p>How can I make an inset method that will add a number into the array in the correct order?</p>
  
  <pre><code>void addElement(int table[], int element, int length) {
      int x = 0;
      int temporary=0;
      cout&lt;&lt;length&lt;&lt;endl;
  
      if(length == 1) {
          table[0] = element;
      }
      else {
          if(length == 2) {
              if (table[0] &gt; element) {
                 int temp = table[0];
                 table[0] = element;
                 table[1] = temp;
              }
              else {
                  table[1] = element;
              }
          }
          else {
              for(int i = 0; i&lt; length &amp;&amp; x == 0; i++) {
                  if(element&lt;table[i] &amp;&amp; element&gt;=table[i-1]) {
                      for(int y = i; y&lt;length; y++) {
                          temporary = table[y+2];
                          int temp = table[y];
                          table[y] = element;
                          table[y+1] = table
                       }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>This is as far as I have gotten. In my main class I have worked it out so that array is increased by 1. So there is one open space at the end of the array for everything to be pushed back by 1.</p>