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
Which part of the computer stores and processes data?
lilavasa [31]

it is A the hardware im pretty sure but dont put my answer in im not completley sure

3 0
3 years ago
What do you think is the most important event in the history of the Internet? What event has had the biggest impact on your dail
lana [24]

Answer:the answer would be this serious when anonimous came to the world or rather when anonymity came

 

Explanation:

The most important events of all the Internet was when anonomous arrived and began to reveal secrets and things against the United States government

 

3 0
3 years ago
Advantages of desktop publishing over traditional methods include       
Licemer1 [7]
From what my teacher taught us it would be c.
6 0
3 years ago
Taking an online class doesn't require any special skills. T or F ? ​
Sidana [21]

Answer:

false

Explanation:

more demanding than regular school

7 0
3 years ago
Select the correct answer.
oee [108]

Answer:

D

Explanation:

3 0
3 years ago
Other questions:
  • Which is a good technique for effectively proofreading your presentation?
    7·1 answer
  • Rachel uses a word processor to write short stories. However, most of her time is spent toying with the keys, rather than in wri
    13·2 answers
  • Considering the following algorithm, which of the following requirements are satisfied?
    9·1 answer
  • All of the following are the four more widely social media networks discussed in the text EXCEPT:
    11·2 answers
  • I was not supposed to upgrade my iPad to iOS 11 due to testing but it automatically did when I was charging it. Is there a way t
    11·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    7·1 answer
  • Technician A says that temperature sensors decrease in resistance as the temperature​ increases; this is called positive tempera
    12·1 answer
  • _______ integrates all departments and functions throughout an organization into a single IT system (or integrated set of IT sys
    5·1 answer
  • Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!