i really need your help guys for data structure and algorithm task my assignment is menu-driven program for array operations in c++ Traversal, Insertion, Deletion, Searching, Sorting i have to perform this in menu to show how they work can you please provide mee code for this

Recommended Answers

All 3 Replies

So far I've yet to see code supplied to requests like this. Here I find help for when I'm stuck. But I do have to show my work and point out where I'm stuck.

-> What step are you stuck on?

commented: i just reply let mee know if u can see down +0

i really need your help guys for data structure and algorithm task my assignment is menu-driven program for array operations in c++ Traversal, Insertion, Deletion, Searching, Sorting i have to perform this in menu to show how they work can you please provide mee code for this so here you can see my code:
#include <iostream>
#include<conio.h>
#include <stdlib.h>
using namespace std;
void traversal(int Arr[], int N);
void insertion(int Arr[], int& N, int Pos, int ITEM);
int lsearch(int Arr[], int N, int item);
void deletee(int Arr[], int& N, int Pos, int ITEM);
void main()

system("cls");
int a[10], n, pos, item, choice, delitem;
char ch;
cout << "\n Enter size:";
cin >> n;
cout << "\n Enter Array:";
for (int i = 0; i < n; i++)
    cin >> a[i];
do
{

    cout << "\n \t\t Menu Driven Program";
    cout << "\n 1. Traversal \n 2. Insertion \n 3. Deletion \n 4. Searching";
    cout << "\n Enter your choice:";
    cin >> choice;
    switch (choice)
    {
    case 1: traversal(a, n);
        break;
    case 2: //Insertion
        cout << "\n Enter Position:";
        cin >> pos;
        cout << "\nEnter Element:";
        cin >> item;
        insertion(a, n, pos, item);
        break;
    case 3: cout << "\n Enter Element to be deleted:";
        cin >> delitem;
        pos = lsearch(a, n, delitem);
        if (pos == -1)
        {
            cout << "\n Element not found";
        }
        deletee(a, n, pos, delitem);
        break;
    case 4: cout << "\n Enter the element to be searched";
        cin >> item;
        pos = lsearch(a, n, item);
        cout << "\n Element found at index:" << pos;
        cout << "\n Element found at position" << pos + 1;
        break;
    default:cout << "wrong choice";
    }
    cout << "\n Do you want to continue?";
    cout << "(Press y/n)";
    cin >> ch;
} while (ch == 'y');
 system("cls");

void traversal(int b[], int N)

for (int i = 0; i < N; i++)
    cout << b[i] << " ";

// Insertion of element into a linear array with functions in c++
void insertion(int A[], int& N, int Pos, int ITEM)

for (int i = N; i >= Pos; i--)
    A[i + 1] = A[i];
A[Pos] = ITEM;
N = N + 1;

// Deletion of element from linear array with functions in c++
void deletee(int A[], int& N, int Pos, int ITEM)

for (int i = Pos; i < N; i++)
    A[i] = A[i + 1];
N = N - 1;
cout << ITEM << " is deleted from the array.";

int lsearch(int A[], int N, int ITEM)

int index = -1;
for (int i = 0; i < N; i++)
{
    if (A[i] == ITEM)
    {
        index = i;
    }
}
return index;

i just need to add here sorting array and it's work that's all i need help mee please

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.