What is the output of following function, if called as fun * (array, 0, 6) array content as follows: 1-2-3-4-5-6 ?
void fun(int array[], int index, int size)
{
if(index >=size)
return;
cout<< array[index];
if(index+1< size)
fun(array , index + 2 ,size);
cout << array[index];
Select one:
a 132551
b. 135531
c.135135
d. 146
Step 1: index= 0, output= 1
Step 2: index= 2, output= 3
Step 3: index= 4, output= 5
Step 4: index= 4, output= 5
Step 5: index= 2, output= 3
Step 6: index= 0, output= 1
Answer: b. 135531
Comments
Leave a comment