I usually get this error how to overcome this

error- source.cpp: In function ‘bool solve(char*, int, int, int, int)’:
source.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
33 | }
| ^

code-- https://ide.codingblocks.com/s/321231

question-- https://hack.codingblocks.com/app/contests/1289/729/problem

Take as input str, a string. The string is a mathematical expression e.g. “[a + {b + (c + d) + e} + f]”. Write a recursive function which tests if the brackets in expression are balanced or not and returns a Boolean value. Print the value returned.

Input Format
Enter the string

Constraints
None

Output Format
Display the boolean result

Sample Input
[a+{b+(c+d)+e}+f]
Sample Output
true

Hey @anubhavb11
add return statement in front of each recursive call

why do we get this error like i am not able to understand why it will not give if i put return in every statement and what can i do for it?

When we dont return something from a function which have a non-void return type then we get this error.
Even this will give the same error:

int solve(){
cout<<1;
}
int main() {

}

actually i just figure out my logic is wrong for test case
)(())(-- it will return true what should i do?

Have you done this problem using stacks ,if u have then try to do it in that way without using stack but by using recursion .
Recursion can be used to itterate the whole string and another array in argument can be treated as stack

Hey,If your doubt is resolved then please mark it resolved :slight_smile:
Otherwise let me know the issue.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.