Skip to main content

Delete Operation

Delete Operation in C++ using class::  By A.P...     " it is used to remove to a data items In the given collection of data items. "            #include "iostream.h"        #include"conio.h"            Class ap                        {                  int arr[100];            public :                    void get_data();                   void del_data();              };             void ap::get_data()        {                 int size, i;            ...

Delete Operation

Delete Operation in C++ using class::


 By A.P...

    " it is used to remove to a data items In the given collection of data items. "

  
        #include "iostream.h"
       #include"conio.h"

     
     Class ap
           
           {

                 int arr[100];

           public :

                   void get_data();
                  void del_data();


             };

            void ap::get_data()

       {
   
            int size, i;
          
          cout <<endl <<"enter array size::";
          cin>>size;
          cout <<endl <<"enter array element";

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

    {
    
         cin>>arr [i];

      }

     }

           void ap::del_data()
     
         {

             int del, count=0;

           cout<<endl<<"enter elements to be deleted ";

          cin>>del;

         for( int i =0; i <size; i++ )
     
         {

               if ( arr [i]=del )
             {
    
                  for( int j=i; j<(size-1); j++)

                    {
                       
                          arr [j]=arr [j+1];
                          count++;
                          break;


                      }
              }
        
                     if ( count==0)
              
                 {
                     
                       cout<<"enter not fount";
     
                   }

                    else
                     {

                          cout <<"new array";
          
                 for (i=0; i <(size-1); i++)
                      
               {
                  cout <<arr [i]<<" ";
               }

       }

                         void main()


              {

                     clrscr();
                      ap obj;
                     Obj.get_data();
                      obj.del_data();
                      getch();

               }


Output ::

                   Enter array size 4
                   enter array element 1
                                                            2
                                                            3
                                                            6
                  Enter element to be deleted 2
                   Now new array 
                   136

Comments

Popular posts from this blog

Object Oriented Programming :

* Object Oriented Programming ::    An OOP (object oriented programming ) is a concepts or programming principle which is used as a latest Programming methodology on which current programming language are based such as--: C++ Java C# Python This programming concept is best suited on which the current software development synory is based. It comprises all expects of software development that are require to developed such software which is perfect accurate and diligent.  The programming approach provide all necessary tool that are needed during development to make software secure smart and expendable. An OOP approach oriented approach which was introduced before the evolution of OOP  concepts procedure . Oriented Language such as C, pascal etc are based on processor oriented programming concept. In procedure programming approach a program is divided into modules or blocks that are know as function or procedure. It was an earlest approach in which ...