Redundant parenthesis is giving segmentation fault pls check and also check the output

https://ide.codingblocks.com/s/364041 dont change the whole code

Before performing the s.top() operation you must always check if the stack is empty or not. s.top() operation on an empty stack will give segmentation fault. So make the necessary changes now.

You can verify the approach from here Redundant parenthesis