toezaurus81
06-15-04, 11:08 AM
/*Define a class intList contains one private attribute:
an array of integers of size 10. Provide member functions to accept
and display the elements of array. Provide one member function that
arranges the array elements in descending order and returns the maximum
of the array elements.
Write a driver program to test the above intList class.*/
#include<iostream.h>
class intList
{
private:
int data[10];
int pass, i, temp;
public:
void accept()
{
cout<<"Input integer number for array";
cout<<"\n******************************"<<endl;
for(i=0;i<10;i++)
{
cout<<"Enter value for array["<<i<<"]: ";
cin>>data[i];
}
}
void display()
{
for(i=0;i<10;i++)
{
cout<<"Value for array["<<i<<"]: "<<data[i]<<endl;
}
}
void arrange()
{ int Max=10;
for(pass=1;pass<=Max-1;pass++)
for(i=0;i<Max-pass;i++)
{
if(data[i]<data[i+1]){
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}
}
}
};
void main(){
intList list;
list.accept();
cout<<"\nThe values stored in the arrays";
cout<<"\n*******************************"<<endl;
list.display();
list.arrange();
cout<<"\nThe values stored in the arrays after sort in decending";
cout<<"\n*******************************"<<endl;
list.display();
//cout<<"The maxinum of the arrays elements: "<<max;
}
an array of integers of size 10. Provide member functions to accept
and display the elements of array. Provide one member function that
arranges the array elements in descending order and returns the maximum
of the array elements.
Write a driver program to test the above intList class.*/
#include<iostream.h>
class intList
{
private:
int data[10];
int pass, i, temp;
public:
void accept()
{
cout<<"Input integer number for array";
cout<<"\n******************************"<<endl;
for(i=0;i<10;i++)
{
cout<<"Enter value for array["<<i<<"]: ";
cin>>data[i];
}
}
void display()
{
for(i=0;i<10;i++)
{
cout<<"Value for array["<<i<<"]: "<<data[i]<<endl;
}
}
void arrange()
{ int Max=10;
for(pass=1;pass<=Max-1;pass++)
for(i=0;i<Max-pass;i++)
{
if(data[i]<data[i+1]){
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}
}
}
};
void main(){
intList list;
list.accept();
cout<<"\nThe values stored in the arrays";
cout<<"\n*******************************"<<endl;
list.display();
list.arrange();
cout<<"\nThe values stored in the arrays after sort in decending";
cout<<"\n*******************************"<<endl;
list.display();
//cout<<"The maxinum of the arrays elements: "<<max;
}