diff --git a/String/BalanceBrackets.cpp b/String/BalanceBrackets.cpp new file mode 100644 index 00000000..8d70b102 --- /dev/null +++ b/String/BalanceBrackets.cpp @@ -0,0 +1,40 @@ +#include +using namespace std; + +// Function to check whether two characters are opening +// and closing of same type. +bool ArePair(char opening,char closing) +{ + if(opening == '(' && closing == ')') return true; + else if(opening == '{' && closing == '}') return true; + else if(opening == '[' && closing == ']') return true; + return false; +} +bool AreParanthesesBalanced(string exp) +{ + stack S; + for(int i =0;i> expression; + if(AreParanthesesBalanced(expression)) + cout << "Balanced\n"; + else + cout << "Not Balanced\n"; +}