logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Functions See What Others Are Saying!
  • Question
  • What will be the output of the following program?
    #include<iostream.h> 
    class Number
    {
        int Num; 
        public:
        Number(int x = 0)
        {
            Num = x;
        }
        void Display(void)
        {
            cout<< Num;
        }
        void Modify(); 
    };
    void Number::Modify()
    {
        int Dec;
        Dec = Num % 13; 
        Num = Num / 13; 
        
             if(Num  > 0 ) Modify()   ; 
             if(Dec == 10) cout<< "A" ; 
        else if(Dec == 11) cout<< "B" ; 
        else if(Dec == 12) cout<< "C" ; 
        else if(Dec == 13) cout<< "D" ;
        else               cout<< Dec ;
    }
    int main()
    {
        Number objNum(130);
        objNum.Modify();
        return 0; 
    }


  • Options
  • A. 130
  • B. A0
  • C. B0
  • D. 90

  • Correct Answer
  • A0 


  • More questions

    • 1. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class PowerFinder
      {
          public:
          void Power(int x = 1, int y = 1)
          {
              int P = 1, i = 1;
              while(++i <= y)
              {
                  P *= x;
              }
              cout<< P << endl; 
          } 
      };
      int main()
      {
          PowerFinder FP; 
          FP.Power(2, 6); 
          return 0;
      }

    • Options
    • A. The program will print the output 12.
    • B. The program will print the output 16.
    • C. The program will print the output 32.
    • D. The program will print the output 36.
    • E. The program will execute infinite time.
    • Discuss
    • 2. What will be the output of the following program?
      #include<iostream.h> 
      class BaseCounter
      {
          protected:
          long int count;
      
          public:
          void CountIt(int x, int y = 10, int z = 20)
          {
              count = 0;
              cout<< x << " " << y << " " << z << endl;
          } 
          BaseCounter()
          {
              count = 0;
          }
          BaseCounter(int x)
          {
              count = x ;
          } 
      }; 
      class DerivedCounter: public BaseCounter
      {
          public:
          DerivedCounter()
          { }
          DerivedCounter(int x): BaseCounter(x) 
          { }
      };
      int main()
      {
          DerivedCounter objDC(30); 
          objDC.CountIt(40, 50); 
          return 0; 
      }

    • Options
    • A. 30 10 20
    • B. Garbage 10 20
    • C. 40 50 20
    • D. 20 40 50
    • E. 40 Garbage Garbage
    • Discuss
    • 3. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          static int x; 
          public:
          static void SetData(int xx)
          {
              this->x = xx; 
          }
          static void Display() 
          {
              cout<< x ;
          }
      };
      int CuriousTab::x = 0; 
      int main()
      {
          CuriousTab::SetData(22);
          CuriousTab::Display();
          return 0; 
      }

    • Options
    • A. The program will print the output 0.
    • B. The program will print the output 22.
    • C. The program will print the output Garbage.
    • D. The program will report compile time error.
    • Discuss
    • 4. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      struct MyStructure
      {
          class MyClass
          {
              public:
              void Display(int x, float y = 97.50, char ch = 'a')
              {
                  cout<< x << " " << y << " " << ch;
              }
          }Cls; 
      }Struc;
       
      int main()
      {
          Struc.Cls.Display(12, 'b');
          return 0; 
      }

    • Options
    • A. The program will print the output 12 97.50 b.
    • B. The program will print the output 12 97.50 a.
    • C. The program will print the output 12 98 a.
    • D. The program will print the output 12 Garbage b.
    • E. The program will print the output 12 Garbage a.
    • Discuss
    • 5. What will be the output of the following program?
      #include<iostream.h> 
      class CuriousTab
      {
          int x, y, z; 
          public:
          void Apply(int xx = 12, int yy = 21, int zz = 9)
          {
              x = xx;
              y = yy += 10;
              z = x -= 2;
          }
          void Display(void)
          {
              cout<< x << " " << y << endl; 
          } 
          void SetValue(int xx, int yy)
          {
              Apply(xx, 0, yy);
          }
      };
      int main()
      {
          CuriousTab *pCuriousTab= new CuriousTab;
         (*pCuriousTab).SetValue(12, 20);
          pCuriousTab->Display();
          delete pCuriousTab;
          return 0; 
      }

    • Options
    • A. 10 10
    • B. 12 10
    • C. 12 21
    • D. 12 31
    • E. The program will report compilation error.
    • Discuss
    • 6. What will be the output of the following program?
      #include<iostream.h> 
      class CuriousTab
      {
          int K; 
          public:
          void CuriousTabFunction(float, int , char);
          void CuriousTabFunction(float, char, char);
          
      };
      int main()
      {
          CuriousTab objIB;
          objIB.CuriousTabFunction(15.09, 'A', char('A' + 'A'));
          return 0;
      }
      void CuriousTab::CuriousTabFunction(float, char y, char z)
      {
          K = int(z);
          K = int(y);
          K = y + z;
          cout<< "K = " << K << endl; 
      }

    • Options
    • A. The program will print the output M = 130.
    • B. The program will print the output M = 195.
    • C. The program will print the output M = -21.
    • D. The program will print the output M = -61.
    • E. The program will report compile time error.
    • Discuss
    • 7. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      int CuriousTabTest(int x, int y);
      int CuriousTabTest(int x, int y, int z = 5);
      int main()
      {
          cout<< CuriousTabTest(2, 4) << endl; 
          return 0;
      }
      int CuriousTabTest(int x, int y)
      {
          return x * y;
      }
      int CuriousTabTest(int x, int y, int z = 5)
      {
          return x * y * z; 
      }

    • Options
    • A. The program will print the output 5.
    • B. The program will print the output 8.
    • C. The program will print the output 40.
    • D. The program will report compile time error.
    • Discuss
    • 8. What will be the output of the following program?
      #include<iostream.h> 
      struct CuriousTab
      {
          int arr[5]; 
          public:
          void CuriousTabFunction(void);
          void Display(void);
      };
      void CuriousTab::Display(void)
      {
          for(int i = 0; i < 5; i++) 
              cout<< arr[i] << " " ;
      }
      void CuriousTab::CuriousTabFunction(void)
      {
          static int i = 0, j = 4; 
          int tmp = arr[i]; 
          arr[i]  = arr[j]; 
          arr[j]  = tmp   ; 
          i++;
          j--;
          if(j != i) CuriousTabFunction();
      }
      int main()
      {
          CuriousTab objCuriousTab = {{ 5, 6, 3, 9, 0 }};
          objCuriousTab.CuriousTabFunction();
          objCuriousTab.Display();
          return 0; 
      }

    • Options
    • A. 0 9 3 6 5
    • B. 9 3 6 5 0
    • C. 5 6 3 9 0
    • D. 5 9 3 6 0
    • Discuss
    • 9. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTabSample
      {
          private:
          int AdditionOne(int x, int y = 1) 
          {
              return x * y;
          }
           
          public:
          int AdditionTwo(int x, int y = 1)
          {
              return x / y;
          } 
      }; 
      int main()
      {
          CuriousTabSample objCuriousTab;
          cout<<objCuriousTab.AdditionOne(4, 8)<<" "; 
          cout<<objCuriousTab.AdditionTwo(8, 8); 
          return 0;
      }

    • Options
    • A. The program will print the output 32 0.
    • B. The program will print the output 32 garbage-value.
    • C. The program will print the output 32 1.
    • D. The program will report compile time error.
    • Discuss
    • 10. What will be the output of the following program?
      #include<iostream.h>
      #include<string.h> 
      class CuriousTabString
      {
          char x[50]; 
          char y[50]; 
          char z[50]; 
          public:
          CuriousTabString()
          { }
          CuriousTabString(char* xx)
          {
              strcpy(x, xx); 
              strcpy(y, xx);
          }
          CuriousTabString(char *xx, char *yy = " C++", char *zz = " Programming!")
          {
              strcpy(z, xx); 
              strcat(z, yy); 
              strcat(z, zz);
          } 
          void Display(void)
          {
          cout<< z << endl;
          } 
      }; 
      int main()
      {
          CuriousTabString objStr("Learn", " Java");
          objStr.Display();
          return 0; 
      }

    • Options
    • A. Java Programming!
    • B. C++ Programming!
    • C. Learn C++ Programming!
    • D. Learn Java Programming!
    • E. Learn Java C++ Programming!
    • Discuss


    Comments

    There are no comments.

Enter a new Comment