How to insert element in array


  • How to insert element in array


  • 1 Comment sorted by



  • #include
    #include
    main()
    {
    int data[10]={10,5,4,19,48,2,34,52};
    int x,n=8,k,item;
    clrscr();
    printf("\nBefore insertion:\n");
    for(x=0;x {
    printf("%d,",data[x]);
    }
    printf("\nEnter item to insert:");
    scanf("%d",&item);
    printf("\nEnter location:");
    scanf("%d",&k);
    for(x=n-1;x>=k;x--)
    {
    data[x+1]=data[x];
    }
    data[k]=item;
    n++;
    printf("\nAfter insertion:\n");
    for(x=0;x {
    printf("%d,",data[x]);
    }
    getch();
    }




Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative