Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 19, Problem 14PC
Program Plan Intro
Balanced Parentheses
Program Plan:
- Include required header files
- Declare function prototype
- Inside “main ()” function,
- Declare a variable “strng”.
- Get a string from the user.
- Check if the Boolean function “is_Balanced ()” returns true.
- If the condition is true then the string has balanced parentheses.
- If the condition is not true then the string does not have balanced parentheses.
- In “is_Balanced ()” function,
- Declare a Boolean variable “status”.
- Create an object for stack.
- Use for loop to step through each character in a string.
- Use Switch…Case structure check the character has set of parentheses or not.
- If left parenthesis is detected,
- Push it into the stack using the function “push ()”.
- If right parenthesis is detected,
- Check if the stack is empty using the function “empty()”.
- If the stack is empty then assign “false”
- If the stack is not empty then assign “true”
- Check if the stack is empty using the function “empty()”.
- If left parenthesis is detected,
- Use Switch…Case structure check the character has set of parentheses or not.
- Check if the stack is empty and assign “true”. Else, assign “false”.
- Return the variable “status”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C programming language
C# language
Write a program that creates a Queue or Stack (your choice) that represents a list of
work orders. This program should use loop, allowing the user to push and pop items
on the stack / queue. The program should also allow the user to print all the items in
the stack / queue to the console.
Strings manipulation in C++ :
Write a program to take input two strings and print the string that is smaller in length.
Chapter 19 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 19.1 - Describe what LIFO means.Ch. 19.1 - What is the difference between static and dynamic...Ch. 19.1 - What are the two primary stack operations?...Ch. 19.1 - What STL types does the STL stack container adapt?Ch. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - What is the difference between a static stack and...Ch. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - The STL stack is considered a container adapter....
Ch. 19 - What types may the STL stack be based on? By...Ch. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - The STL stack container is an adapter for the...Ch. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 21RQECh. 19 - Prob. 22RQECh. 19 - Prob. 23RQECh. 19 - Prob. 24RQECh. 19 - Prob. 25RQECh. 19 - Prob. 26RQECh. 19 - Write two different code segments that may be used...Ch. 19 - Prob. 28RQECh. 19 - Prob. 29RQECh. 19 - Prob. 30RQECh. 19 - Prob. 31RQECh. 19 - Prob. 32RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Dynamic String Stack Design a class that stores...Ch. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PCCh. 19 - Prob. 11PCCh. 19 - Inventory Bin Stack Design an inventory class that...Ch. 19 - Prob. 13PCCh. 19 - Prob. 14PCCh. 19 - Prob. 15PC
Knowledge Booster
Similar questions
- Python Language - Bad Luck Numbersarrow_forwardGiven a set of items where each item contains a weight and value, determine the number of each to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. Implement statement in c# programarrow_forwardPython questions: 1) When using a stack to evaluate the balance of brackets and parentheses in an expression, what is the final step? a. at the end of the expression, if a final closing bracket is found, the brackets balance b. at the end of the expression, if the stack is empty, the brackets balance C. at the end of the expression, if the stack is full, the brackets balance d. at the end of the expression, if the stack is empty, the brackets do not balance 2)If the current state of the stack is [x, y, z, t, r] where x is the bottom of the stack and r is the top of the stack, what is the state of the stack and the value returned after two pops operation a. the state is [z, t, r]; x, y are returned b. the state is [x, y]; z, t, r are returned C. the state is [y, z]; x, t, r are returned d. the state is [x, y, z]; t, r are returned 3)What is the resulting postfix expression from the following infix expression? 12 + 5 * 2 - 3 a. 12 5 2^ * +3 - b. 12 5 +2 3^ * - C. 12 5 +2^ *…arrow_forward
- -)Write a C++ program that presents a menu for the user. The menu should consist of the following: Create a linked list of 5 nodes containing names and phone numbers. Insert a new structure in the linked list. (between the 4 and the 5 node) Modify an existing structure in the linked list.(modify node 4) Delete an existing structure from the list (delete node 5) Exit from the program Note: based on the user’s selection the program should execute a function to satisfy the request. (Items: 3, 4, and 5,)arrow_forwardplease answer all parts within 30 minutes ..arrow_forwardJava - Contains the Characterarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning