Insert Value in array

 

#include<iostream>

using namespace std;

int main()

{

    //INsert 8 at 4th index shift other element

    int k,i;

    int length=5;// number of element

    int mimo[10]={2,3,5,6,7};

    int x=8;// value will be insert

    int index=4;

    for (i=length;i>index;i–)

    {

        mimo[i]=mimo[i-1];

        }

        mimo[index]=x;length++;

    for ( i = 0; i <10 ; i++)

    {

        cout<<mimo[i]<<endl;

    }

    return 0;

} // 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top