Write a program to check the proper pairing of braces. The program will have two
variables, one to keep track of the left braces and the other to keep track of the right
braces. They both start at value 0 and the appropriate one is incremented each time a
brace is encountered.If the right brace variable ever exceeds the value of the left brace
variable, the program inserts the character pair ?? at that point in the output. If, at
the end of the input file, the left brace variable is greater than the right brace variable,
the program should print a message that include the number of missing right braces as
a series of that many }s.What output is produced for the input }{}{? Do you think that the output is correct?
Try to rectify the algorithm so that the output is }??{}{ 1 missing }.
variables, one to keep track of the left braces and the other to keep track of the right
braces. They both start at value 0 and the appropriate one is incremented each time a
brace is encountered.If the right brace variable ever exceeds the value of the left brace
variable, the program inserts the character pair ?? at that point in the output. If, at
the end of the input file, the left brace variable is greater than the right brace variable,
the program should print a message that include the number of missing right braces as
a series of that many }s.What output is produced for the input }{}{? Do you think that the output is correct?
Try to rectify the algorithm so that the output is }??{}{ 1 missing }.
Comment