Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program in C This lab is designed to give you practice working with pointers and memory allocation. Getting Started To start this exercise, you should

Program in C image text in transcribed
This lab is designed to give you practice working with pointers and memory allocation. Getting Started To start this exercise, you should 1. Open eclipse and create a new C project named Lab06 2. Add a Source File (named lab06.c) to this project Problem Description 1. You are to write a complete C program that creates a stack (of float values) that is initially empty (top 0), and has a capacity of exactly one 2. You are to write a function that when given your stack, its top, its capacity, and a float value to be pushed, will return a pointer to a stack that is identical to the given stack but with the new value pushed on top. Note, if the given stack is already full, you will need to: e create a new stack that is twice the size of the given stack copy all the current values from the given stack to the new stack, preserving their order copy the given new value into the new stack at location top free the stack pointed to by the given stack argument . modify the given top and capacity arguments to reflex the changes e return the address of the new stack via the functions return value if the stack is NOT already fu, you will need to: copy the given new valuc into the stack pointed to by the given stack argument at location top modify the given top to reflex the change return the address of the given stack via the functions return value 3. Notice that in this model, a push "never" fails . 4. You are to add code to your program's main function in order to verify that your function is working correctly with you stack. Hint: its capacity will at all times be a power of 2 1, 2, 4, 8, 16, . 5. Once you have written your Program and function (a) Make sure that your program compiles and runs without errors or warnings (b) Run your program enough times to check all the cases for correctness. (c) If it runs correctly, then see your TA for a check-off

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions