Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Delete

 Delete - Data Structure


#include<iostream>

using namespace std;


int main()

{

    int arr[50];


    int n;

    cout<<"Enter the size of Array: ";

    cin>>n;


    cout<<"Enter elements of Array: ";

    for(int i=0; i<n; i++)

        cin>>arr[i];


    int index;

    cout<<"Enter Index No: ";

    cin>>index;

    if(index<0 || index>=n)

    {

        cout<<"Insertion is not possible!"<<endl;

    }

    else{

        for(int i=index; i<n-1; i++)

            arr[i]=arr[i+1];

        n--;

    }


    cout<<"Your Array is :";

    for(int i=0; i<n; i++)

        cout<<"  "<<arr[i];

}


Post a Comment

0 Comments