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 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
Post a Comment