Home / C++ Programming / Functions - C++ :: Programs

C++ Programming :: Functions - C++

  1. Which of the following statement is correct about the program given below?

     #include 
     class PowerFinder
     {  
       public:  
       void Power(int x = 1, int y = 1)      
       {       
           int P = 1, i = 1;         
           while(++i coutint main() 
           {                   
          PowerFinder FP;     
          FP.Power(2, 6);     
          return 0;
     }
    

  2. 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.

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following statement is correct about the program given below?

     #include
     void Tester(float xx, float yy = 5.0);  
     class Freshergate
     {   
           float x;    
           float y;     
           public:    
           void Tester(float xx, float 5.0)       
           {  
               x = xx;     
               y = yy;       
               cout   int main() 
       {    
         Freshergate objGate;      
         objGate.Tester(5.0, 5.0);     
         return 0; 
      }
    

  4. A.

    The program will print the output 0.

    B.

    The program will print the output 1.

    C.

    The program will print the output 2.

    D.

    The program will print the output garbage value.

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following statement is correct about the program given below?

     #include const double GateConstant(const cons0);
     int main()
     {    
         const int c = 2 ;   
         cout10)" ";      
         cout20)     return 0;
     }
     const double  Gateconstant(const int x, const int y)
     {    
       return( (y + (y * x) * x % y) * 0.2); 
     }
    

  6. A.

    The program will print the output 2 4.

    B.

    The program will print the output 20 40.

    C.

    The program will print the output 10 20.

    D.

    The program will print the output 20 4.50.

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following statement is correct about the program given below?

      #include 
      struct MyStructure
      {   
          class MyClass   
          {      
             public:     
            void Display(int x, float y = 97.50, char ch = 'a')    
            {         
               cout" " int main()
     {   
         Struc.Cls.Display(12, 'b');  
         return 0; 
     }
    

  8. 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.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following statement is correct about the program given below?

      #include
      long FactFinder(long = 5); 
      int main() 
      {   
         for(int i = 0; i0; i++)         
            cout     return 0;
     }
     long FactFinder(long x) 
     {    
         if(x 2)     
            return 1;    
        long fact = 1;     
        for(long i = 1; i 1; i++)         
          fact = fact * i;  
        return fact;  
    }
    

  10. A.

    The program will print the output 1.

    B.

    The program will print the output 24.

    C.

    The program will print the output 120.

    D.

    The program will print the output garbage value.

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the following program?

      #include
      double GateFunction(double, double= 0,  
      double = 0, double = 0);
      int main()
      {    
          double d = 2.3;  
          cout7) " ";     
          cout7, 6)       return 0;
      } 
          double GateFunction(double x, double p, double q, double r, double s)
     {  
         return p +(q +(r + s * x)* x) * x; 
     }
    

  12. A.

    7 20

    B.

    7 19.8

    C.

    7 Garbage

    D.

    7 20.8

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the following program?

        #include
        int main()
        {   
           float Amount;    
           float Calculate(float P = 5.0, int N = 2, float R = 2.0);   
           Amount = Calculate();    
           coutreturn 0;
       }
    
        float Calculate(float P, int N, float R)
        {    
           int Year = 1;  
           float Sum = 1 ;   
           Sum = Sum * (1 + P * ++N * R);    
           Year =  (int)(Year + Sum);   
           return Year;  
       }
    

  14. A.

    21

    B.

    22

    C.

    31

    D.

    32

    E.

    None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the following program?

      #include
      class Gate
      {     
          int x, y;    
          public:    
          void show(void);     
          void main(void); 
     };
     void Gate::show(void)
     {  
        Gate b;   
        b.x = 2;  
        b.y = 4;   
        cout" " void Gate::main(void)
     {   
         Gate b;    
         b.x = 6;   
         b.y = 8;     
         b.show();
     }
     int main(int argc, char *argv[])
     {   
         Gate run;   
         run.main();  
         return 0;  
    }
    

  16. A.

    2 4

    B.

    6 8

    C.

    The program will report error on Compilation.

    D.

    The program will report error on Linking.

    E.

    The program will report error on Run-time.

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statement is correct about the program given below?

     #include 
     classFreshergateSample 
     {   
         private:   
         int AdditionOne(int x, int y = 1)     
         {        
            return x * y;     
         }       
         public:     
         int AdditionTwo(int x, int y = 1)    
         {    
            return x / y;   
         } 
     };  
     int main() 
     {  
         Freshergateesample objGate;    
         cout4, 8)" ";      
         cout8, 8);      
         return 0;
     }
    

  18. 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.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the following program?

      #include
      class Freshergate
      {    
          int K;    
          public:    
          void GateFunction(float, int , char);     
          void GateFunction(float, char, char);        
     };
     int main()
     { 
        FreshergatebjIB;     
        objIB.GateFunction(15.09, 'A', char('A' + 'A'));   
        return 0; 
     }
     void Freshergate:Gatefunction(float, char y, char z)
     {    
         K = int(z);   
         K = int(y);   
         K = y + z;     
         cout"K = " 

     

     

  20. 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.

    View Answer

    Workspace

    Discuss Discuss in Forum