ERROR: Control may reach end of non-void function /

If you call the function with a first argument of 0 the loop is never executed and the return statement is, thus, never reached. Falling of the end of a non-void function is undefined behavior. My personal guess is that the return statement was meant to one level up, i.e., in the out block: this would guarantee that the function always returns … Read more

Error: control may reach end of non-void function in C

You are getting this error because if your for loop breaks due to breaking condition i < n; then it don’t find any return statement after for loop (see the below, I mentioned in code as comment). If for loop break due to i >= n then control comes to the position where I commented and there is no return statement present. Hence you are getting an error “reach … Read more