Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Kindly help,its all 1 question,thumbs up is a must ECE 361: Computer Organization - Fall 2018 October 31, 2018 Page 5 of 9 Name: Question

Kindly help,its all 1 question,thumbs up is a must image text in transcribed
image text in transcribed
image text in transcribed
ECE 361: Computer Organization - Fall 2018 October 31, 2018 Page 5 of 9 Name: Question 2(30 pts)-Cstruct and pointers WARNING: READ THE PROBLEM CAREFULLY, THE ORGANZATION OF THE STACK is SMLAR TO THAT OF PROBLEM ASKS FOR. USE DESCRIPTIVE VARIABLE NAMES AND COMMENT AS APPROPRIATE. In this problem we are going to code small pieces of a stack module that operates on food STACKADT2. CIN C PROGRAMMING: A MODERN APPROACH, BUT II'S NOT THE SAME, PROVIDE WHAT THE items. Each food item has the following structure: typedef struct food_item // name of the food // number of calories per serving // number of servings per, container char namell; int calPerServing; int numservings; ) food itemt; Homework #3 asked you to code a stack module with a fixed size array. Now we'd like you to code the stack with a dynamically allocated array of food items. You can assume the following struct for the stack struct stack_type ( food_item t *contents; /1 the array of food items int top int size; // top of stack pointer // the stack's maximum size (the // the number of food items) struct stack type theStack; You can also assume the availability of a function static void terminate(const char *message) that displays a message and terminates the application Write the following 6 functions (use the starter code on the next 2 pages) int create(int size) allocates space for the food item array and initializes top and size. size is the maximum number of food items that can be stored on the st void destroy(void) - frees up the memory allocated to the food item array and resets top and size to0 bool is_empty(void) returns true if the stack is empty, false otherwise bool is_full(void) that returns true if the stack is full, false otherwise void push(food_item_t item) - pushes item onto the stack. The function should ack terminate if the stack is full food item t pop(void) - that pops the top item on the stack and returns it in a food item struct. The function should terminate if the stack is full. Don't forget to declare a variable to return the food item to. (huk sa

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

Move smoothly from point to point

Answered: 1 week ago