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
lawyer [7]
3 years ago
14

Write a program that inputs a line of text and uses a stack object to print the line reversed.

Computers and Technology
1 answer:
Lina20 [59]3 years ago
8 0

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

   string ms;

   getline(cin,ms);

   stack<char>st;

   for(int i=0;i<ms.length();i++)//Inserting every element in the stack..

   {

       st.push(ms[i]);

   }

   while(!st.empty()) //doing operation until the stack is not empty..

   {

       char a=st.top();//accessing the top element of the stack...

       st.pop();//removing the head.

       cout<<a;//printing the character..

   }

return 0;

}

Input:-

murder

Ouput:-

redrum

Explanation:

An  easy way to reverse anything is to use stack.Since stack is LIFO type data structure so the last item in will be the first one to get out hence it reverses the elements.So inserting every element of the string into the stack of characters and then printing the every element of the stack from top to bottom.

You might be interested in
What is a very important difference there between the wiring of an electromechanical thermostat and an electronic programmable t
valentinak56 [21]

Answer:

A mechanical thermostat will typically use a bimetal strip with two different metals that expand/contract with the temperature at different rates.

Explanation:

7 0
2 years ago
0 50 100 150 200 250 300 350 400 Shape Size These shapes are the correct 50 01 100 150 Pattern Reference If you don't have red,
cricket20 [7]

Answer:

0 540 100 200 350 400 550 600 750

Explanation:

hope this helped

4 0
3 years ago
Read 2 more answers
If you enter the search "genetically modified foods" in a database, the double quotes around the three words will:
In-s [12.5K]

Answer:

Have a more specified search

Explanation:

If you do this in G0OGLE Then it will be the same thing all it basically does it narrow down the search to find more of what you want

4 0
2 years ago
________ software consists of operating systems, utilities, device drivers, and language translators.
Hunter-Best [27]

Answer:

"System"

Explanation:

<u>System</u> software consists of operating systems, utilities, device drivers, and language translators.

(not much explanation as it was a fill in the blank which explains itself haha)

Have a nice day!

    I hope this is what you are looking for, but if not - comment! I will edit and update my answer accordingly. (ノ^∇^)

- Heather

3 0
2 years ago
Organ transplants are rarely successful.
Maurinko [17]

False......................

6 0
3 years ago
Other questions:
  • 3. If B3=6 and D5=8, what would the following function return? IF(B3&gt;D5, "Closed", D5-B3) *
    10·2 answers
  • Digital cameras are less susceptible to UV light.Select one of the options below as your answer:A. TrueB. False
    15·2 answers
  • In general, use no more than _____ font types in a worksheet.
    11·1 answer
  • A URL suffix is called a domain name.
    11·1 answer
  • What is the difference between an electronic notebook and electronic flash cards?
    8·1 answer
  • If data from a DOS system is electronically sent to an EHR or other Windows-based system via an interface to populate an indexed
    7·1 answer
  • In general, the farther you are from other road users, the A. lower your crash risk B.higher your crash risk C. slower they are
    6·1 answer
  • Create a new class MyArray_DE and copy and paste the previous program. Be sure to rename the class to MyArray_DE. Modify the pro
    14·1 answer
  • 1. What is the difference between a group and a topic?
    10·1 answer
  • What are the real-life applications of coding?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!