Home Forums C Programming C++ Object Oriented Programming Arrays and Pointer

Viewing 0 reply threads
  • Author
    Posts
    • #2033
      veenisha
      Participant

      Let us discuss how to use arrays and Pointers in C++.

      Here i made a program, in which arrays are used in making a class.
       

      numbers criteria.cpp
       
      /*
       Muhammad Atif Agha
       Punjab University
       College of Information Technology
       PUCIT
       BSCSF06M081
           */
       
       
      #include
      #include
      #include
      //Program which tells us from an Array that which Number is bigger than how many numbers in an Array

      class A{
      private:
      int size;
      char arr[80];
      public:
      A()
      {
      size=0;
      }
      void setfunc (char a[],int s)
      {
       strcpy(arr,a);
       size=s;
      }
       
      void fun (char arr[],int s);
       

      void showfunc()
      {
       cout<  cout< }

      };
      // Outside the class

      void A::fun(char arr[],int size)
      {
           int i,j;
           for (i=0;i      {
       int count=0;
       for (j=0;j     {
        if (arr>arr[j])
        count=count+1;
          }
          cout< }
            }

      int main(){
      clrscr();
      A a1,a2;
      int i;
      char array[80];
      int s;
      cout<<"Enter the size"< cin>>s;
      cout< for (i=0;i {
      cin>>array;
      }
      a1.setfunc(array,s);
      a2.fun(array,s);
      getch();
      return 0;
      }

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.