Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Other answers on chegg are incorrect. Please solve this specific question. It is different. Copied answers will get a thumbs down. [Acua] Implement a counter

Other answers on chegg are incorrect. Please solve this specific question. It is different. Copied answers will get a thumbs down.
image text in transcribed
image text in transcribed
[Acua] Implement a counter ADT using a struct and four functions. A counter is a simple device we can use to count up from zero. (Think of the clickers that are used to count the number of people that pass a door or who are in an audience. The struct contains a string for the counter's name, and a number for the value. Create four functions: create_counter (creates a counter based on a name, initializes the count, and returns it), increment (takes a counter and increases it value by one), tally (returns the value of a counter), and display (prints out the counter with the format "NAME shows VALUE."). Assume that the name never has more than 255 characters. The specific syntax for these functions is shown indirectly in the main. #include //for malloc# #include Ila struct to contain counter information struct counter { char name[256]; int count; }; //function to create counters struct counter* create_counter(char* name) { #include //for malloch #include Wa struct to contain counter information struct counter { char name[256]; int count; }; 7/function to create counters struct counter* create_counter(char* name) { //function to increment a counter void increment(counter* c) { //function to get a counter's tally int tally(counter* c) { V/function to display a counter's tally void display(counter* c) { //SAMPLE USAGE void main() { struct counter* c1 - create_counter("First"); struct counter* c2 - ci; increment (c1); increment(c2): display(c1); //output: First shows 2. display(c2); //output: First shows 2. }

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago