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
You are working with a worksheet on which cell B3 is selected. You hold down the Ctrl key and the Shift key and click cell B6. W
Keith_Richards [23]

Answer:

"B3 and B6 will selected"

Explanation:

  • If the worksheet is opened by the user and he is in the cell B3, then the B3 and B6 are selected, If the user clicks the B6 after pressing the ctrl and the shift key.
  • The shift and ctrl are used to select any two cells in the MS-Excel worksheet.
  • The above question asked about which cell is selected when the user in on cell B3 and press the B6 while holding the ctrl and shift key. So the answer is "B3 and B6".
8 0
3 years ago
The two key elements of any computer system are the____and the _____.
Virty [35]
Easy.
Hardware and software!
Did you ever try to use a computer with only mouse and monitor?
8 0
3 years ago
Consider the following line of code: price= input(Please enter the price: ") What would be the next line in your code that will
hodyreva [135]

Answer:

price float(price)

Explanation:

There are four basic type of data type use in the programming to declare the

variable.

1. int:  it is used for integer values.

2. float:  it is used for decimal values.

3. char:  it is used for character values

4. Boolean: it is used for true or false.

in the question, the one option contain the data type float (price float(price)). So, it store the value in decimal.

price int(price):  it store the value in integer.

price decimal(price):  it is wrong declaration of variable. their is no data type in the programming which name is decimal.

price price(decimal):  it is wrong declaration of variable. their is no data type in the programming which name is price.

6 0
3 years ago
You want to securely erase data from your hard drive what can you use to do this and what is the process called
tankabanditka [31]
You could Factory Reset a computer or you could smash it with  a hammer
7 0
3 years ago
Read 2 more answers
Can somebody hack ur account on Brainly bc I feel like I have bc I have answered waaaaaay more questions than shows on my profil
QveST [7]
It says you’ve only answered 11, but yeah it you’re account CAN be hacked
4 0
3 years ago
Other questions:
  • g c 24-hour time (also known in the U.S. as military time) is widely used around the world. Time is expressed as hours since mid
    7·1 answer
  • Which type of word processing programs enables us to include illustrations within the program?
    6·1 answer
  • You have a computer at home. The computer is connected to the Internet through a dial-up connection. Every time you connect to t
    7·1 answer
  • LEAF library in py can be expressed in what form?
    6·1 answer
  • If you were infiltrating a network (10.16.0.0/16), and searching for vulnerabilities (while trying to remain undetected), why wo
    11·2 answers
  • HELP!! TIMED TEST!! Match the item to its description. 1. icons place where frequently used programs can be opened 2. Quick Laun
    13·1 answer
  • Help mah!!! T^T please and thank you mate
    5·2 answers
  • Write a program called array1.cpp file that use either regular for loop or range based for loop to display the contents of the a
    14·1 answer
  • 2. What is the MOST common experience LGBTQ+ individuals share when accessing medical trea
    9·1 answer
  • How do you properly turn off a computer?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!