#include<stdio.h>
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) 5
b) 6
c) 7
d) 8
How many times is the function recursive_search_num() called when the following code is executed?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
How many times is the function recursive_search_num() called when the following code is executed?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!