Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that reads in a sequence of characters and prints them in reversed order. You must use a stack. Implement these two

Write a C++ program that reads in a sequence of characters and prints them in reversed order. You must use a stack. Implement these two function prototypes.

1. void push(char *stack, int top, char c);

2. char pop(char *stack, int top);

Use provided driver program to test your code. You should get the same output.

***********************DRIVER PROGRAM********************

int main()

{

string str;

cout<<"Please input a string: "<

cin>>str;

char *stack;

stack =new char[str.length()];

int top=0;

for(int i=0;i

{

push(stack,top,str[i]);

}

for(int j=0;j

{

cout<

top--;

}

}

input and output:

Please input a string:

abcdefg

gfedcba

Program ended with exit code: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

Students also viewed these Databases questions