Given an array of length n and an integer x, you need to find and return the first index of integer x present in the array. Return -1 if it is not present in the array. First index means, the index of first occurrence of x in the input array.
Answers
Answered by
0
Answer:
ifkfjdhdgjdjfkfkgkfkgkf
Answered by
0
Ans
Explanation:
#include<iostream>
using namespace std;
int first_index(int arr[],int size,int val,int real_size){
if(size==0){
return -1;
}
else if(*(arr)==val){
return real_size-size+1;
}
int ans=first_index(arr+1,size-1,val,real_size);
return ans;
}
int main(){
int arr[7]={1,2,3,4,5,6,7};
cout<<first_index(arr,7,4,7);
return 0;
}
Similar questions
Math,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
English,
1 year ago
Math,
1 year ago