Getting unknown error

this is the code for last occurance.
my code-https://ide.codingblocks.com/s/253592

i am getting an error and i face this error many time, please tell me why this error is occurring and how to debug this error.

and also tell me if my approch to solve this problem is wrong or right

Hello @shivamgoel150,

  1. 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.

  1. Also, you have missed the court statement.

  2. 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.