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

C++ Programming :: Functions - C++

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

     #include
     long GateFunction(int x, int y = 5, float z = 5) 
     {   
          return(++x * ++y + (int)++z); 
     } 
     int main() 
     {   
        cout20, 10);     
        return 0;
     }
    

  2. A.

    237

    B.

    242

    C.

    240

    D.

    35

    E.

    The program will report error on compilation.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include
     int GateFunction(int a, int b = 3, int c = 3) 
     {  
          coutreturn 0; 
     }
     int main()
     {
         GateFunction(5, 0, 0);    
         return 0; 
     }
    

  4. A.

    8

    B.

    6

    C.

    -6

    D.

    -8

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      void MyFunction(int a, int b = 40) 
      {   
          cout" a = "" b = "
      }
       int main() 
      {   
         MyFunction(20, 30);   
         return 0; 
      }
    

  6. A.

    a = 20 b = 40

    B.

    a = 20 b = 30

    C.

    a = 20 b = Garbage

    D.

    a = Garbage b = 40

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      static int b = 0; 
      void DisplayData(int *x, int *y = &b)  
      {   
         cout" int a = 10, b = 20 ;      
          DisplayData(&a, &b);  
          return 0; 
      }

     

  8. A.

    The program will print the output 10 20.

    B.

    The program will print the output 10 0.

    C.

    The program will print the output 10 garbage.

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      typedef void(*FunPtr)(int); 
      int Look(int = 10, int = 20);
      void Note(int); 
      int main()
      {
         FunPtr ptr = Note;   
         (*ptr)(30);    
         return 0; 
     } 
     int Look(int x, int y) 
     {  
        return(x + y % 20); 
     } 
     void Note(int x) 
    {   
       cout

  10. A.

    10

    B.

    20

    C.

    30

    D.

    40

    E.

    Compilation fails.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      class Freshergate
      {   
        public:    
       void Gate(int x = 15)   
       {        
            x = x/2;        
            if(x > 0)        
                Gate();       
             else        
                cout2;   
       }  
     }; 
     int main() 
     {   
        FreshergateobjIB;   
        objIB.Gate;    
        return 0;  
    }
    

  12. A.

    The program will display 1.

    B.

    The program will display 2.

    C.

    The program will display 15.

    D.

    The program will go into an infinite loop.

    E.

    The program will report error on compilation.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    #include
     long GetNumber(long int Number) 
     { 
        return --Number; 
     } 
     float GetNumber(int Number)
     {   
       return ++Number; 
     } 
     int main() 
     {     
        int x = 20;   
        int y = 30;   
        cout" ";      
        cout
        return 0;  
    }
    

  14. A.

    The program will print the output 19 31.

    B.

    The program will print the output 20 30.

    C.

    The program will print the output 21 31.

    D.

    The program will print the output 21 29.

    E.

    Program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      struct MyData
      {  
        public:    
       int Addition(int a, int b = 10)    
       {        
          return (a *= b + 2);     
     }  
       float Addition(int a, float b); 
     };
     int main() 
     {    
         MyData data;
        cout1)" ";       
        cout3, 4);     
        return 0; 
      }
    

  16. A.

    12 12

    B.

    12 18

    C.

    3 14

    D.

    18 12

    E.

    Compilation fails.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include
     int GateTest(int x, int y);
     int GateTest(int x, int y, intz=5);

      int main()

     {
    cout2, 4)

    return 0;

    }

    int GateTest(int x, int y)

    {

       return x * y; }

      int GateTest(int x, int y, int z = )   {

      return x * y * z;

    }

     

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

    View Answer

    Workspace

    Discuss Discuss in Forum


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

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

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