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
____ takes the idea of breaking down a program into separate and reusable functions to the next level by focusing on the encapsu
STALIN [3.7K]
The answer is Object-oriented programming (OOP). This is a type of programming language model on the concept of "objects", which may comprise of data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. The first step here is to classify all the objects the programmer wants to work and how they relate to each other, this is known as data modeling. Once an object has been identified, it is generalized as a class of objects which describes the type of data it comprises and any logic sequences that can manipulate it.
6 0
4 years ago
In cell E12, enter a formula to calculate the % of Budget by dividing the Actual expense by the Budget expense to indicate the p
AVprozaik [17]

Answer:

I have made the required file and it is attached. Hope that helps :)

Download xlsx
3 0
3 years ago
Wrtie a program in which we will pass a value N. N can be positive or negative. If N is positive then output all values from N d
Triss [41]

Answer:

Following are the answer to this question:

x=int(input("Enter number: "))#defining x variable that input value from user end

if x< 0:#defining if block that check x value is less then 0

   while x<0:#defining while loop print up to the value

       print(x)#print value

       x+= 1#add values by 1

elif x>0:#defining elif block to check value x is greater than 0

   while x>0:#defining while loop to print down to value

       print(x)#print value

       x-= 1#subtract value by 1

Output:

when input is a positive value

Enter number: 5

5

4

3

2

1

when input is a negative value

Enter number: -5

-5

-4

-3

-2

-1

Explanation:

  • In the given python code, x variable is declared that input the value from the user end, in the next step if and elseif block is declared that calculates and prints its value.
  • In the if block, it checks value is negative it uses the while loop to prints its values in the down to value form.
  • In the elif block, it checks the positive it uses the while loop to prints its values into the up to values form.  
5 0
4 years ago
Plz I need the answer!!!:(
dimaraw [331]

Answer:

Procedural, Visual, Logic - Based

Explanation:

7 0
3 years ago
Whereas enterprise network convergence focuses on the consolidation of traditionally distinct voice, video, and data communicati
Vinil7 [7]

Answer: Unified communication

Explanation: Unified communication is the communication technique in which merges various communication routines into a individual business.It works as the phone system which helps in increment of productivity in an organizational business.

The unifying of voice,data/information,video etc is done for optimizing and improving the business that also results in  faster communication rates, secure communication etc.

4 0
3 years ago
Other questions:
  • You will use the _____
    15·2 answers
  • Acrynom for wys or wyg
    10·1 answer
  • The two variables causing the point of difference between the time codes are the frequency and the count
    6·1 answer
  • Pressing the Ctrl+Home keys moves the insertion point to the
    12·2 answers
  • the part of the computer that provides access to the internet is the A.modem B. keyboard C. monitor or D.system unit
    7·2 answers
  • What is an Odometer (Driver's Ed)
    7·2 answers
  • How can I unblock Brainly?
    12·2 answers
  • While creating a digital portfolio, Harry wants to add documents that authenticate his skills, experience, and knowledge in digi
    11·1 answer
  • Identify a possible IOT (internet of Things) device in a smart kitchen and write a use case for interacting with the software of
    12·1 answer
  • How to transfer word 2019 from one computer to another
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!