Create an array list.
Use class and call the basic functions in main
Note:no global declarations
#include<iostream.h>
class arraylist
{
int a[6];
public:
void getelts()
{
cout<<”Enter 6 numbers in the array:”<<endl;
for(int i=0;i<6;i++)
{
cin>>a[i];
}
}
void show()
{
cout<<”\nArray elements are”<<endl;
for(int i=0;i<6;i++)
{
cout<<a[i]<<endl;
}
}
};
void main()
{
arraylist obj;
obj.getelts();
obj.show();
}
Comments
Leave a comment