An empty sequence of characters is considered balanced. So if the input consists only of a #, then the program should say yes.
You can presume that the input contains no blanks.
You can read a character using operator >>, and a variable of type char. For example,
char c; cin >> c;causes the next character to be read and put into c. (Precisely, it skips over spaces and newlines to reach the next non-white-space character, and puts that into c.)
You will find it convenient never to consume the # character until after you have read the entire input and reached a conclusion about whether it is balanced. You can use cin.peek() to get the next character without consuming it. For example, do
c = cin.peek();If you do cin.peek() several times in a row, you will keep getting the same character. Unlike operator >>, peek does not skip over blanks. If you see anything but a #, then remove it from the input using operator >>. If you see a #, leave it there. Do not make it the main program's responsibility to consume the #. Think about who should have that responsibility.
Character constants are formed using single quote marks. For example, the left parenthesis character is written ')' in a C++ program.
Test your program on several inputs. Try #, ((#, )# and ()()()#, among others.