Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program Specification: A stack is a container that can be defined in terms of an array where all adds are preformed at the end of
Program Specification: A stack is a container that can be defined in terms of an array where all adds are preformed at the end of the sequence of existing values, and all removes are also preformed at end of the sequence of existing values. An empty stack is one that has no existing values in the array at all. We use the notion of top of the stack to keep track of (at which index) a new value in the sequence is to be added. Hence, an empty stack is one in which top is equal to 0 and a full stack is one in which top is equal to the array's physical size - capacity. For this assignment, you will write a C program to create and use an array based stack Requirement:s You must write a C program which satisfies the following Your C program must dynamically allocate the memory for the underlying array of float values, with a capacity of 1024. Your C program must dynamically free this memory before termination Your C program must declare and define functions to Create an empty stack (of float values) with a capacity of 1024 Test to see if the stack is empty Test to see if the stack is full Push (add) an item (a float value) onto the stack - if not already full Pop (remove) an item (a float value) from the stack - if not already empty Your C program must define a main function to fully test all of the above funcionality. Notes: 1. A stack is really three separate data items (a) a float pointer to the array (b) an int top index indicator an int capacity (physical size of the array 2. The effective size of the stack (number of items in the stack) can be deduced from the top index indicator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started