Simple algorithm To Create, Insert, Delete, and Display elements in an array.

Array

Algorithm

  1. Start
  2. Initialize an array arr[MAX] and a variable n (number of elements).
  3. Create:
    • Ask user for n.
    • Read n elements into the array.
  4. Menu:
    • Display options:
      1. Insert
      2. Delete
      3. Display
      4. Exit
  5. Insert Operation:
    • Ask for position pos and value val.
    • Shift elements from pos to the right.
    • Insert val at pos.
    • Increment n.
  6. Delete Operation:
    • Ask for position pos.
    • Shift elements from pos+1 to left.
    • Decrement n.
  7. Display Operation:
    • Print all n elements of the array.
  8. Repeat menu until Exit is selected.
  9. Stop

Flowchart

Leave a comment