Hello @shivamgoel150,
- The error you are getting is common in function with return type non-void.
Let’s understand why are you getting this warning:
warning: control reaches the end of non-void function
The function you have defined has a return type int:
int last_occurance(int *a,int first,int last,int key)
that means it will surely return some integer value.
But, you have end the definition of this function without returning anything.
Solution:
The last statement of these function should be a return statement always.
-
Also, you have missed the court statement.
-
Yes, the logic is correct as you are finding the first occurrence of the element from last.
Corrected Code:
Hope, this would help.
Give a like if you are satisfied.