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
Why is Touchpad used in the laptop computer​
Ber [7]

Answer:

in controlling the mouse or cursor

Explanation:

as is it known tha a cursor is a poniting device. and the only way to control it without a mouse is the touchpad

3 0
3 years ago
In the context of customer relationship management (CRM) applications, which approach is often chosen by organizations with an e
Bad White [126]

The on-premise approach is often chosen by organizations with an established IT infrastructure.

<h3>What is the On Premises?</h3>

In an on-premises method, resources are said to be given or deployed in-house and it is one that is found within an enterprise's IT infrastructure.

Customer relationship management (CRM) is known to be a form of a technology that is often used in the act of managing all of a firm's  relationships and communications with customers and also that of potential customers.

Therefore, The on-premise approach is often chosen by organizations with an established IT infrastructure.

Learn more about CRM from

brainly.com/question/27373018

#SPJ1

5 0
2 years ago
Given an alphanumeric string made up of digits and lower case ASCII characters only, find the sum of all the digit characters in
lara31 [8.8K]

Answer:

C++.

Explanation:

#include <iostream>

#include <string>

using namespace std;

////////////////////////////////////////////////////////////////////////////

int sumDigits(string alphanumeric) {

   if (alphanumeric.length() == 1) {

       if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {

           cout<<int(alphanumeric[0]) - 48<<endl;

           return (int(alphanumeric[0]) - 48);

       }

       else

           return 0;

   }

   else {

       if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {

           cout<<int(alphanumeric[0]) - 48<<endl;

           return int(alphanumeric[0]) - 48 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));

       }

       else

           return 0 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));

   }

}

////////////////////////////////////////////////////////////////////////////

int main() {

   cout<<"Sum: "<<sumDigits("ab1c2d3e54");

   return 0;

}

3 0
3 years ago
Why when I put a question in the search bar it says something went wrong?
xz_007 [3.2K]
It’s says the same thing to me too!
8 0
3 years ago
Explain the working system of a computer with an example.​
Phoenix [80]

Answer:

A computer system works by combining input, storage space, processing, and output. ... For example, when we type something using a keyboard, it is known as an Input provided to the Computer. Storage Space: It is the place where our input gets stored. It is known as Computer Memory that keeps the data into it.

hope. It helps

can you mark. Me as brinelist

8 0
3 years ago
Other questions:
  • Will mark brainliest if correct. First come, first serve.
    15·1 answer
  • When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string??
    12·1 answer
  • Why is it important to have regular maintenance and care of your office equipment?
    5·1 answer
  • PLEASE HELP!!!!
    7·1 answer
  • How do you use a iPad when it has a password ?
    9·2 answers
  • Was LDAP version2 an internet standard in 1998? is it now?
    5·1 answer
  • Justify the need for branching and jump codes in the instruction set using real world scenarios
    6·1 answer
  • Write a program in java to enter a character.The program displays the message "uppercase vowel" if entered character is uppercas
    5·1 answer
  • Execute and explain this program using // in Layman's language. Thank you!
    7·1 answer
  • The specialized programs used by the operating systems to help ensure that memory is used properly and there are no memory confl
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!