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
Wireless networks usually use ____ signals to send data.
barxatty [35]
<span>Wireless networks usually use radio (b) signals to send data. </span>
6 0
3 years ago
Read 2 more answers
Earthquakes happen in the Earth’s
Nostrana [21]
Earthquakes happen in the Earths "CRUST" because all of the tetonical plates are located in the crust.

hope this helped
5 0
3 years ago
Which job role requires you to create user guides for computer products and services?
kipiarov [429]

For plato I think technical writer is the answer.

Technical writer: As a technical writer, you’ll create user manuals and support guides for a number of computer products and services. You may also develop content to market technical products online.

4 0
3 years ago
Read 2 more answers
3.5 lesson practice quiz Edhesive
erik [133]

Answer:

                                                                                     

Explanation:

6 0
2 years ago
Read 2 more answers
Which of the following would an A/V technician NOT typically do? (Select all that apply).
nydimaria [60]
Where is the options?
7 0
3 years ago
Other questions:
  • Help! live preview in brackets is not working
    8·1 answer
  • Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
    5·1 answer
  • WHERE WAS THE CHEESEBURGER INVENTED?
    9·1 answer
  • 1. What is Java SE?
    11·2 answers
  • Potatocat2UwU da best
    12·1 answer
  • A server of service is responsible for sending the contents of cengage.com to your browser when you type cengage.com into the lo
    12·1 answer
  • Gemima wants to order the different kinds of food alphabetically on the table. Which actions should she take? Check all that app
    8·2 answers
  • How are Earth's plates made?
    14·1 answer
  • Write python code that does the following: Ask the user to enter as many as number they want; Then find the sum and the average
    10·1 answer
  • Why is it important to prepare the farm resources before you start working? explain​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!