Question: I need a checkDelimeters functions to do this lab. Please help. #include #include #include using namespace std; // Declaration function checkDelimiters int main() { cout

I need a checkDelimeters functions to do this lab. Please help.

I need a checkDelimeters functions to do this lab. Please help. #include

#include

#include

#include

using namespace std;

// Declaration function checkDelimiters

int main()

{

cout

bool done = false;

do

{

cout

string inputLine;

char ch = 'a';

cin.get(ch);

while (cin && ch != ' ')

{

inputLine += ch;

cin.get(ch);

}

if (checkDelimiters(inputLine))

cout

else

cout

cout

char again = 'y';

cin >> ch;

if (toupper(ch) == 'N')

done = true;

else

{

cin.clear();

cin.ignore(INT_MAX, ' ');

}

} while (!done);

cout

system("Pause");

return 0;

}

// Definition function checkDelimiters

Lab 13: Stacks One of the tasks that compilers must frequently perform is checking whether some pair of expression delimiters are properly paired, even if they are embedded multiple pairs deep Consider the following C++ statement: a (func (b)-(c+d))/2; The compiler has to be able to determine which pairs of opening and closing parentheses go together and whether the whole expression is correctly parenthesized. A number of possible errors can occur because of incomplete pairs of parentheses, or because improperly placed parentheses. For example, the statement below is missing a closing parenthesis. a (func (b)-(c+d)/2; A stack is extremely helpful in implementing a solution to this type of problem because of its LIFO behavior. A closing parenthesis needs to be matched with the most recently encountered opening parenthesis; this is handled by pushing opening parentheses onto a stack as they are encountered. When a closing parenthesis is encountered, it should be possible to pop the matching opening parenthesis off the stack. If it is determined that every closing parenthesis had a matching opening parenthesis, then the expression is valid. The start project contains a main function that asks the user to enter an expression (a C++ statement) to check its validity. You need to implement the function checkDelimiters by passing the expression as a string and using a stack to check its validity Possible output This program checks for properly matched delimiters. nter delimited expression: (func (b) - (c +d)) 2; alid heck another one? (y) y Enter delimited expression: a(func (b) (c +d) / 2; Invali heck another one? (y)n Press any key to continue

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!