
Write a python code
Input
Your program will take an arithmetic expression as a String input. For Example:
- “1+2*(3/4)”
- “1+2*[3*3+{4–5(6(7/8/9)+10)–11+(12*8)]+14”
- “1+2*[3*3+{4–5(6(7/8/9)+10)}–11+(12*8)/{13+13}]+14”
Program
Your program will determine whether the open brackets (the square brackets, curly braces and the parentheses) are closed in the correct order.
Outputs:
Output 1
1+2*(3/4)
This expression is correct.
Output 2
1+2*[3*3+{4–5(6(7/8/9)+10)–11+(12*8)]+14
This expression is NOT correct.
Error at character # 10. ‘{‘- not closed.
Output 3
1+2*[3*3+{4–5(6(7/8/9)+10)}–11+(12*8)/{13+13}]+14
This expression is correct.
Output 4
1+2]*[3*3+{4–5(6(7/8/9)+10)–11+(12*8)]+14
This expression is NOT correct.
Error at character # 4. ‘]‘- not opened.
Task -
Solve the above problem using an array based stack.

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Write a program to print all fibonacci numbers less than k, where k is a non-negative integer taken input from the user. Given: k < 1000. Programming language: C++arrow_forwardWrite a program to print all fibonacci numbers less than k, where k is a non-negative integer taken input from the user. Given: k < 1000. Programming language: C++arrow_forwardPlease write me an python (We cannot have while true and break)arrow_forward
- Write a JAVASCRIPT code to repeat the given string to n times and add to it the original string without using loops concat, + operator. for example:- n = 4 given string:- Programmer Output:- ProgrammerProgrammerProgrammerProgrammerarrow_forwardJAVA Write a java program that takes a string as input from the user and finds out if the string is a palindrome or not. A string is a palindrome if it reads the same from forward as well as from backward. For example, the string “madam” is a palindrome. Use a for loop to solve this problem. Sample inputs and outputs: Input: madam Output: palindrome Input: Dad Output: palindrome Input: hello Output: not a palindromearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





