1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
expeople1 [14]
3 years ago
11

Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres

sion contains matching grouping symbols. For example, the arithmetic expressions {25 + (3 – 6) * 8} and 7 + 8 * 2 contains matching grouping symbols. However, the expression 5 + {(13 + 7) / 8 - 2 * 9 does not contain matching grouping symbols. If the expression contains matching grouping symbols, the program output should contain the following text: Expression has matching grouping symbol If the expression does not contain matching grouping symbols, the program output should contain the following text:

Computers and Technology
1 answer:
IceJOKER [234]3 years ago
6 0

Answer:

See explaination for the details of the answer.

Explanation:

#include <iostream>

#include <stack>

using namespace std;

int main(){

string str;

cout<<"Enter a String: ";

std::getline (std::cin,str);

bool flag=true;

stack<char> st;

for(int i=0;i<str.size();i++){

if( (str.at(i)>='0' && str.at(i)<='9') || str.at(i)=='+' || str.at(i)=='-' || str.at(i)=='/'|| str.at(i)=='*' || str.at(i)==' ' ){

// cout<<str.at(i) <<"came"<<endl;

continue;

}

if( str.at(i)=='{' || str.at(i)=='(' ){

st.push(str.at(i));

}

else if(!st.empty() &&((st.top() == '{' && str.at(i) == '}') || (st.top() == '(' && str.at(i) == ')')))

st.pop();

else{

flag=false;

break;

}

}

if(!st.empty()){

cout<<"Does not match"<<"\n";

}else{

if(flag)

cout<<"Match"<<"\n";

else

cout<<"Does not match"<<"\n";

}

return 0;

}

See attachment for the output.

You might be interested in
Which of the main value components are contained in the value proposition "SportsAde offers serious athletes a great-tasting way
Elina [12.6K]

Answer:

Explanation:unique difference/benefits

- "a great-tasting way to stay hydrated during exercise" this is the benefit statement

2. product/service category or concept is

- the drink

3. target market

- "serious athletes" is the target market

4. offering name or brand is

- SportsAde

5 0
3 years ago
Which type of data is presented on the y-axis?
den301095 [7]
For example, if I was foong a bar graph about the amounts of what was in different jars, the x-axis would have the items in the jars, and the y-axis woukd have the amount of items in the jars
6 0
3 years ago
Read 2 more answers
Raj needs to apply sorting to a current list in his Word document.
dmitriy555 [2]

Answer:

Home tab styles group

Explanation:

Edjenuity 2020

4 0
3 years ago
Read 2 more answers
Horizontal scaling of a client/server architecture means _____.
Irina-Kira [14]

Answer:

D. I think

Explanation:

7 0
3 years ago
Help Menu is available at which button in the keyboard?
kvasek [131]
Answer: It should be F1.
6 0
3 years ago
Other questions:
  • What type of file can most software applications read?
    5·2 answers
  • Which method deletes a footer from a document?
    9·2 answers
  • Which type of computing device is best suited to having a digital pen as an input device?
    9·1 answer
  • Create a list of consent rules to live by​
    5·1 answer
  • Tuple in Python code help pleaseee!!! And of course I'll make you as Branlist
    11·1 answer
  • What is the main difference between project tasks and client support tickets?
    11·1 answer
  • True or False<br> humans shed skin in their sleep (pwease fweinds onwy answer)
    15·1 answer
  • photoshop Curves, photoshop an image and manipulate the curves on a selection of the photo. upload the original photo and The ph
    5·2 answers
  • Why is it important to register your software when you install it
    15·1 answer
  • Give 3 reasons why it is believed that smart phones precent us from communicating face to face.give three reasons why it is beli
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!