Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please design a C program to implement a stack using pointers. Let the user operate the stack and output its content. The user have two

Please design a C program to implement a stack using pointers. Let the user operate the stack and output its content.

The user have two input method:

1)Digit 1+blank space + Number N. This input method is push. The number N is the number to be pushed into the stack. You should refresh the stack status. Ex;(1 23),(1 5), (1, 45) ...

2)Digit 2 . This input method is pop. When it is detected that the users previous input is 2

The top element in the stack should be removed.

The program should let the user input indefinitely until EOF is detected.

The program must contain two functions:

1) Void mypush(int) : It takes an integer N that will be pushed to the stack.

2)Int mypop(): remove the top element in the stack and output the remaining elements of the stack. The function should be able to judge when there is no element to be removed in the stack and print an error message.

Note that the built-in push and pop function cannot be used.

image text in transcribed

Digital x New Tab O Complex pdm.pdf x Inverse x M 1091_CX > Home X Google X M Chegg. X C Get Her x C Digitex + File C:/Users/USER/Downloads/HomeWork11%20(2).pdf DO HomeWork14 (2).pdf 2/3 Please input the instruction:1 444 push 444 into stack. Example: Nothing in stack Please input the instruction:2 Error pop- Nothing in stack. Please input the instruction:1 3 push 3 into stack. 3 444 20. Please input the instruction:1.5 push 5 into stack. Please input the instruction:19 push 9 into stack. Puns 9 Please input the instruction:1 20 push 20 into stack 444 20 20 que Please input the instruction:1 444 Please input the instruction:2 push 444 into stack. pop 9 from stack. Please input the instruction 2 pop 9 from stack RRRRRR

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

Step: 3

blur-text-image

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

10. 10x+8y = -20 11. 3x-y=-8 5x+2y=5

Answered: 1 week ago