Delete Number from Linear Array Index

#include<iostream>
using namespace std;
main()
{
int arr[10]={10,20,40,55,60,70,80,90};

int n=8;// n is number of element existing right now in array

        int k=1;// k is the specific index number from where values to delete
        
        int item=arr[k];

int j=k;
while(j<=n-1)
{
arr[j]=arr[j+1];
j++;
}
n--;// number of element decreases by 1

        for(int i=0;i<=n;i++)
{
cout<<arr[i]<<"  ";
}
}

SHARE
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment