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

Discussion :: Functions - C++

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

    
     #include 
     struct GateArray 
     {   
         int arr[5];    
         public:    
         void GateFunction();    
         void Display();
     }; 
     void GateArray::GateFunction()
     {     
         static int i = 0, j = 4;  
         i++;   
         j--;    
         if(j > 0)      
             GateFunction();     
        int tmp = arr[i];    
        arr[i]  = arr[j];     
        arr[j]  = tmp;  
        i--;   
        j++; 
     }
     void GateArray::Display()
     {  
        for(int i = 0; i 5; i++)         
          cout" ";
     } 
     int main() 
     {   
         GateArray objArr = {{5, 6, 3, 9, 0}};     
         objArr.GateFunction();     
         objArr.Display(); 
         return 0;  
    

  2. A.

    5 6 3 9 0

    B.

    0 9 3 6 5

    C.

    0 5 6 3 9

    D.

    0 6 3 9 5

    E.

    None of these

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    No answer description available for this question.


Be The First To Comment