Friday, 18 January 2013

Insertion and deletion in Array[]



  #include <iostream>
  #include <conio>


/*****************************************************/

               class insert

         {

           private:

             int arr[6],a,b,s,d,i;

             public:

             insert()

             {
              s=5;d=0;
             }
              void input()

              {
               cout<<"Plz Enter element into Array[]\n";

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

               {
                cin>>arr[i];
               }



              }

                 void show()

                 {
                  cerr<<"Your desir Array[] is\n";

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

                  {
                   cerr<<arr[i]<<" ";
                  }






                 }

                   void put()

                   {

                    cprintf("Your desir Array[] After performing operation is\n");

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

                  {
                   cerr<<arr[i]<<" ";
                  }

                   }


                   void in()

                   {     cout<<endl<<endl;
                    cout<<"Enter index for insertion\t";cin>>a;

                    for(i=5;i>=a;i--)

                    {
                     arr[s]=arr[s-1];s--;
                    }

                     cerr<<"Enter element:\t";cin>>arr[a];
                   }


                     void del()

                     {
                        cout<<endl<<endl;
                      cout<<"Enter index for Deleletion\t";cin>>b;

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

                     {
                      arr[s]=arr[s];s++;
                     }
                     cout<<"Enter elment\t";cin>>arr[b];

                     }




         };

           void main()

           {
                   insert p;

                   p.input();
                   p.show();
                   p.in();

                   p.put();
                   p.del();
                   p.put();
           getch();}

0 comments:

Post a Comment