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
For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
Paul [167]

Answer:

  • Interactive media
  • Information services and support
  • Programming and software development
  • Network systems administration

Explanation:

The company has finished designing a software program, but users aren’t sure how to use it. <u>interactive media</u>

Several people in the human resources department need new software installed. <u>information services and support</u>

An employee has an idea for a software program that can save the company time, but doesn’t know how to write it. <u> programming and software development</u>

A new branch of the company is opening soon, and the computers there need to be connected to the Internet. <u>network systems administration</u>

<u>OAmalOHopeO</u>

3 0
2 years ago
What is composition
Dmitry [639]
The term composition in simple words is “putting together”. It is a thing composed of various elements.
4 0
2 years ago
In critical thinking, an argument is:
djverab [1.8K]
C... it’s c ok.......................
6 0
2 years ago
Read 2 more answers
Orphan record example?
Goryan [66]

Answer:

If we delete record number 15 in a primary table, but there's still a related table with the value of 15, we end up with an orphaned record. Here, the related table contains a foreign key value that doesn't exist in the primary key field of the primary table. This has resulted in an “orphaned record”.

4 0
2 years ago
As related to the use of computers, ____ is defined as gaining unauthorized access or obtaining confidential information by taki
solong [7]

Answer:

Option(B) i.e., social engineering  is the correct option to the question.

Explanation:

The following option is correct because social engineering is the type of attack in which the criminals tricks the computer users to disclose the confidential data or information. Criminals or hackers use this trick because by this they can easily take advantage of your confidential information or corporate secrets.

4 0
3 years ago
Other questions:
  • Technology offers a variety of rich opportunities available to teachers and students. According to Inan and Lowther (2010), ther
    6·1 answer
  • What does the headgear of a mine do
    6·2 answers
  • The standing toe touch is most likely to result in
    15·1 answer
  • Which best describes color blindness?
    8·1 answer
  • Downloading files is safe for most types of files except Select one: a. documents. b. pictures. c. executable files. d. music fi
    7·1 answer
  • What is the name of the technology that is typically implemented on switches to avoid Ethernet connectivity problems when the wr
    11·1 answer
  • ppose we have a Rectangle class that includes length and width attributes, of type int, both set by the constructor. Define an e
    9·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
  • Using the Insert tab, you can convert text into a table and a table into text.
    15·1 answer
  • PLEASE HELP!
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!