array

Write classes Array that contain the Array of integers as data members. The class contain the member functions:

  • A constructor that initializes the Array element to -1
  • Input function to input the values in Array
  • Show function to display the values of Array
  • A member function to make the values of Array two times

 

#include<iostream>
#include<conio.h>
using namespace std;
class array {
     private:
          int arry[10];  
     public:
          array(){
              arry[10] = -1;
          }
          void input(){                
              cout<<"Enter values to array:";
              for(int x=0;x<=9;x++){
              cin>>arry[x];
              }
          }
          void show(){                 
              cout<<"\nThe values of array is:";
              for(int y=0;y<=9;y++){
              cout<<endl<<arry[y];
              }
          }
          void twotimes(){
              cout<<"\nThe values of array Two Time greater:";
              for(int z=0;z<=9;z++){
                   cout<<endl<<2*arry[z];
              }
          }
};

int main(){
     array a1;
     a1.input();
     a1.show();
     a1.twotimes();
     getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *