Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you are not interested in STL containers(although I would advice you to look into it for eg <code>vector</code>), declare an array of whatever maximum size you want</p> <pre><code>int arr[10]; </code></pre> <p>Now access the elements in an array through indexing and assign the value</p> <pre><code>arr[0] = 5; //indexes start from 0 and in this case till 9 </code></pre> <p>Or keep a variable for index as</p> <pre><code>int index = 0; </code></pre> <p>While inserting, use:</p> <pre><code>arr[index] = value; index++; </code></pre> <p>While making an element in array available, just decrement the index to point that the later indexes are free to be filled.</p> <p>EDIT:</p> <p>See the code below:</p> <pre><code>#include&lt;iostream&gt; using namespace std; int main() { int arr[10]; int choice; int num; int index = 0; do { cout&lt;&lt;"enter you choice:\n"; cout&lt;&lt;"1. add number\n"; cout&lt;&lt;"2. delete number\n"; cout&lt;&lt;"3. display memory\n"; cout&lt;&lt;"anything else to exit\n"; cin&gt;&gt;choice; switch(choice) { case 1: if(index==10) { cout&lt;&lt;"no more space available\n"; } else { cout&lt;&lt;"enter number: "; cin&gt;&gt;num; arr[index++] = num; } break; case 2: if(index==0) { cout&lt;&lt;"memory empty\n"; } else { cout&lt;&lt;"item deleted!\n "; index--; } break; case 3: for(int i = 0;i&lt;index;i++) { cout&lt;&lt;arr[i]&lt;&lt;'\t'; } cout&lt;&lt;endl; break; default: cout&lt;&lt;"exiting......."; } }while(choice&gt;0 &amp;&amp; choice&lt;4); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload