Is_Balanced( Binary Tree )

One test case is not running .
And also if I remove the line “cout<<endl;” from the main it is giving wrong answer.Tell me why?

actually it is print garbage value as you have to assigned p.balance in else case

Modified Code

actually you have to use else condition also
see at line no 75 in modified code

also the correct condition is
abs(left.height - right.height) <= 1

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask