Program that checks if a String has balanced parenthesis/bracket/curly brace.


The goal of this project is to get used to working with the following topics in C:

  1. Dynamic memory allocation
  2. Pointers
  3. Reading from stdin

Project Instructions

Create a C program (named parentheses.c) that will:

  1. Create a function that accepts will check if a single string is a valid string.
  2. Accept strings from stdin until an EOF signal is received (each string will be on it's own line).
  3. For each string, call the function you created in step 1 to check if the string contains valid parentheticals:
  • A string is valid if every open parenthesis/bracket/curly brace is closed by the correct brace and nested correctly
  • Example 1: (djfk[kfdsj{012}hello]world) is valid
  • Example 2: (hello[how{are]youtoday}) is not valid because the closing ] is encountered before the closing }
  • Example 3: (()[{()}][]) is valid
  • Example 4: [(a)(b)(c){d[b]} is not valid because there is no closing ] matching the first opening [.

For every string, print out a line that simply says VALID or NOT VALID (this will be case sensitive). These lines should occur in the same order the strings are read in and there should be no additional lines or additional text.

Hints: there may be other characters in addition to parentheses, curly braces, and brakcets. However, these characters will not affect whether the string is valid (only the parenthetical type characters matter).

Get Help With a similar task to - Program that checks if a String has balanced parenthesis/bracket/curly brace.

Login to view and/or buy answers.. or post an answer

Related Questions

Similar orders to Program that checks if a String has balanced parenthesis/bracket/curly brace.
Advance topics in machine learning (Kernels) 2 questions.
Any 2/3 Questions need answering on Advance topics in machine learning (Kernels). relevant notes can be shared upon request....
Using R programming to perform functions and do work.
The expectations are to use R programming to answer the questions attached the file, and the result is also to be a .r file....
write up a report using c programming.
Using the knowledge acquired from this module write a descriptive report to solve the programming problems listed below. The word count limit is 500 words You must include the full code implementation as appendix! I recommend you use Courier New size 1...
Analyse requirements and select appropriate solutions. Design programmes that use appropriate data structures
The assignment requires you to select and implement appropriate data structures, design and implement algorithms and create the relevant software applications that will allow a user to store, update and manipulate the data relating to the operations of an...