Functions

Q1:
What will be the output of the following program?
#include<iostream.h> 
struct AptitudeArray
{
    int arr[5]; 
    public:
    void AptitudeFunction();
    void Display();
};
void AptitudeArray::AptitudeFunction()
{
    static int i = 0, j = 4; 
    i++;
    j--;
    if(j > 0)
        AptitudeFunction(); 
    int tmp = arr[i]; 
    arr[i]  = arr[j]; 
    arr[j]  = tmp; 
    i--;
    j++;
}
void AptitudeArray::Display()
{
    for(int i = 0; i < 5; i++)
        cout<< arr[i] << ' ';
} 
int main()
{
    AptitudeArray objArr = {{5, 6, 3, 9, 0}};
    objArr.AptitudeFunction();
    objArr.Display();
    return 0; 
}

A 0 9 3 6 5

B 0 6 3 9 5

C None of these

D 0 5 6 3 9

E 5 6 3 9 0

ANS:D - 0 6 3 9 5

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.