Vidyalelo
Data Structure · Q929

Miscellaneous on Data Structures

Programming · Data Structure · question 929

Q929

What is the output of the following code? #include int recursive_search_num(int *arr, int num, int idx, int len) if(idx == len) return -1; if(arr[idx] == num) return idx; return recursive_search_num(arr, num, idx+1, len); int main() int arr[8] =1,2,3,3,3,5,6,7,num=5,len = 8; int indx = recursive_search_num(arr,num,0,len); printf("Index of %d is %d",num,indx); return 0;

A.
Index of 5 is 5
Answer
B.
Index of 5 is 6
C.
Index of 5 is 7
D.
Index of 5 is 8

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board