Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to give you practice with manipulating character arrays and with writing subroutines to a given specification. An eccentric soda

The purpose of this assignment is to give you practice with manipulating character arrays and with writing subroutines to a given specification. An eccentric soda lover stores his soda in a cellar that can hold 40 cans. He always keeps cans of a particular type next to each other so he can easily determine how many cans of a particular type he has. Once placed in the cellar, a can is never moved to another location. Input: An input consists of an integer (N) optionally followed by a character (C). If N is zero, the program terminates If N is positive, it is followed by a character and represents the purchase of N cans of type C. If N is negative, it is followed by a character and represents the consumption of N cans of type C. Output: After each N,C pair your program outputs a depiction of the cellar possibly preceded by an error message (see example beginning on the next page) You will be given a partiallycompleted template of a Pep/9 program that updates an array representing the cellar as soda is bought and consumed. Your assignment is to complete the program by writing five subroutines specified by their Ctype prototypes as follows: int count (char C) // returns number of sodas of type C in cellar void remove (int N, char C) // removes the first N sodas of C in the cellar void fill (int N,int I,char C) // inserts N instances of C starting at cellar[I] void find (char C, int *first, int *last) // updates reference parameters with indexes of first and last C void fillleft (int Start, int N, char C) // puts N instances of C, leftwards starting at cellar [Start]

This code must be written in C.

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Question What integration level should an employer choose?

Answered: 1 week ago