Question: C program #include #include #include #include #include int main (int argc, char *argv[]){ // Your code here return 0; } (C program) You are going
C program

#include
int main (int argc, char *argv[]){ // Your code here return 0; }
(C program) You are going to write a program to check whether the parentheses are balanced or not. For example, "( ( ) ) ( ) " is a balanced parentheses, 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 (zero-based) that you spot 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 "lab3-q3.c". Input file: A string contains (),[] and \{\} only. The length of input will not exceed 100 characters. Qutput 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 zero-based number. Sample 1 Input: (())() Sample 1 Output: There are 3 balanced parentheses. Sample 2 Input: (())( Sample 2 Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
