Question: Question 3 : Matching Parentheses ( 3 0 % ) You are going to write a program to check whether the parentheses are balanced or
Question : Matching Parentheses
You are going to write a program to check whether the parentheses are balanced or not. For
example, is a balanced parenthese, while and are
unbalanced. There are three types of parentheses, which are and If the
parentheses are balanced, you need to output the number of matching parentheses. If the
parentheses are unbalanced, you need to output the first position zerobased that you spot
an error.
Your program should read the input from the file, and output the answer to another file. The
first argument is the input file name, while the second argument is the output file name.
Name your program as labqc
Input file: A string contains and only. The length of input will not exceed
characters.
Output file: If the parentheses are balanced, output There are X balanced
parentheses. If the parentheses are unbalanced, output Error is spot at position
Y at first. Y is a zerobased number. For the Sample below, the error occurs at the
position of
Sample Input:
Sample Output:
There are balanced parentheses.
Sample Input:
Sample Output:
Error is spot at position at first.
Sample Input:
Sample Output:
Error is spot at position at first.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
