Question: Write program in C++ Compilers check your program for syntax errors, but a missing brace, parenthesis, or bracket may cause the compiler to output many

Write program in C++
Write program in C++ Compilers check your program for syntax errors, but

Compilers check your program for syntax errors, but a missing brace, parenthesis, or bracket may cause the compiler to output many errors without identifying the instruction that caused the malformed instruction. The goal of this assignment is for you to write a program that checks a string of symbols to determine whether the symbols are balanced. For simplicity, your program will only need to consider the braces'l'. 1' and parentheses C. y. Examples of legal and illegal sequences are below: 00-legal (01 - illegal (0) - legal (01) - legal The following algorithm uses a stack data structure for its solution. Make an empty stack Read characters to end of line of the character is an opening symbol, push it onto the stack If the character is a closing symbol and the stack is empty, print an error message Otherwise, pop the stack If the symbol is not the corresponding opening symbol then report an error If you have reached the end of line and the stack is not empty, then report an error, else print legal Repeat until you reach the end file. The requirements of the assignment are: Your program should be implemented in either Cor C++. You are to implement your own stack functions, including push() and pop(). Your program should read its input from a file. You may assume that each line of the file will contain a string of symbols, and the number of characters in each string will not exceed 255. An easy way to implement a stack is to use an array and maintain an index to the top of the stack. You may initialize this index to -1 to indicate that the stack is empty

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!