Posted by MindBreaker at 1:46 AM
Read our previous post
Object:
Write a program delete number 4th
from an array
Source Code;
#include <iostream>
using namespace std;
class del
{
public:
int
*arry(int arr[10],int
e,int t)
{
int
elements=e;
int
total=t;
int
position;
for (
elements = 0 ; elements < total ; elements++ )
{
if(arr[elements]==14)
{
position=elements;
}
else
{
position=1;
}
}
for(elements=position;elements<total-1;elements++)
{
arr[elements]=arr[elements+1];
}
return
arr;
}
};
void
main()
{
del dl;
int
arr[100], position, elements, total,*ptr;
cout<<"Enter
number of elements"<<endl;
cin>>total;
cout<<"Enter
elements";
for (
elements = 0 ; elements < total ; elements++ )
{
cin>>arr[elements];
}
ptr=dl.arry(arr,elements,total);
cout<<"Resultant
is : "<<endl;
for(elements=0;elements<total-1;elements++)
{cout<<ptr[elements]<<endl;}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.