How do I code the C code for the main.c file to accomplish the following tasks outlined in the assignment (see images) to produce a similar palindromes output?
How do I code the C code for the main.c file to accomplish the following tasks outlined in the assignment (see images) to produce a similar palindromes output?
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Topic Video
Question
C PROGRAM!!!!
How do I code the C code for the main.c file to accomplish the following tasks outlined in the assignment (see images) to produce a similar palindromes output?
![## Lab Exercise Reference Guide
### File Descriptions:
- **main.c**: Contains the main function code.
- **lab5.c**: Includes code specific to carrying out this lab exercise.
- **lab5.h**: Header definitions for functions specific to carrying out this lab exercise.
- **dynarray.c**: Includes a dynamic array set of structures and functions for stacks and queues.
- **dynarray.h**: Header definitions for functions used for stacks and queues.
- **makefile**: A makefile that facilitates the creation of the “queue” executable (including clean commands).
### Functions in dynarray.c
#### Dynamic Array Struct Definition:
```c
typedef dynarray_t;
```
This line creates a type definition for a dynamic array struct referred to as `dynarray_t`.
### Basic/Common Operations:
1. **Initialize Struct**:
```c
void dynarray_init(dynarray_t *a);
```
- Initializes the dynamic array structure.
2. **Free Struct**:
```c
void dynarray_free(dynarray_t *a);
```
- Frees the memory allocated for the dynamic array structure.
3. **Return Element Count**:
```c
size_t dynarray_size(dynarray_t *a);
```
- Returns the count of elements in the dynamic array.
4. **Check if Empty**:
```c
size_t dynarray_is_empty(dynarray_t *a);
```
- Returns true if the dynamic array is empty.
### Stack Operations:
1. **Add to Back**:
```c
void dynarray_push(dynarray_t *a, data_t item);
```
- Adds an element to the back of the stack.
2. **Remove from Back**:
```c
data_t dynarray_pop(dynarray_t *a);
```
- Removes an element from the back of the stack.
3. **Return Back**:
```c
data_t dynarray_top(dynarray_t *a);
```
- Returns the element at the back of the stack.
### Queue Operations:
1. **Add to Back**:
```c
void dynarray_enqueue(dynarray_t *a, data_t item);
```
- Adds an element to the back of the queue.
2. **Remove from Front**:
```c
data](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8cb58778-70ba-4f7e-90ce-7267bd79a013%2F95ecd4d8-c9e4-4454-9c33-8ceb7216946e%2Funsw66_processed.png&w=3840&q=75)
Transcribed Image Text:## Lab Exercise Reference Guide
### File Descriptions:
- **main.c**: Contains the main function code.
- **lab5.c**: Includes code specific to carrying out this lab exercise.
- **lab5.h**: Header definitions for functions specific to carrying out this lab exercise.
- **dynarray.c**: Includes a dynamic array set of structures and functions for stacks and queues.
- **dynarray.h**: Header definitions for functions used for stacks and queues.
- **makefile**: A makefile that facilitates the creation of the “queue” executable (including clean commands).
### Functions in dynarray.c
#### Dynamic Array Struct Definition:
```c
typedef dynarray_t;
```
This line creates a type definition for a dynamic array struct referred to as `dynarray_t`.
### Basic/Common Operations:
1. **Initialize Struct**:
```c
void dynarray_init(dynarray_t *a);
```
- Initializes the dynamic array structure.
2. **Free Struct**:
```c
void dynarray_free(dynarray_t *a);
```
- Frees the memory allocated for the dynamic array structure.
3. **Return Element Count**:
```c
size_t dynarray_size(dynarray_t *a);
```
- Returns the count of elements in the dynamic array.
4. **Check if Empty**:
```c
size_t dynarray_is_empty(dynarray_t *a);
```
- Returns true if the dynamic array is empty.
### Stack Operations:
1. **Add to Back**:
```c
void dynarray_push(dynarray_t *a, data_t item);
```
- Adds an element to the back of the stack.
2. **Remove from Back**:
```c
data_t dynarray_pop(dynarray_t *a);
```
- Removes an element from the back of the stack.
3. **Return Back**:
```c
data_t dynarray_top(dynarray_t *a);
```
- Returns the element at the back of the stack.
### Queue Operations:
1. **Add to Back**:
```c
void dynarray_enqueue(dynarray_t *a, data_t item);
```
- Adds an element to the back of the queue.
2. **Remove from Front**:
```c
data
![## Palindromes
A palindrome is a string that is identical to itself when reversed. For example, "madam", "dad", and "abba" are palindromes. Note: the empty string is a palindrome, as is every string of length one.
Write some code in the `main()` function to accomplish the following tasks:
- **Prompt for User Input**: Having written code to extract data from the keyboard (`stdin`) in Lab 3, reuse that code to prompt the user to enter a string between 0 and 255 characters in length. You should ignore whitespace and punctuation, and all comparisons should be case-insensitive.
- **Process User Input**: Process the entries from the keyboard and store them in the queue ADT provided in the lab 5 code package.
- **Check for Palindromes**: Use the `is_palindrome()` function ADT provided to implement a simple palindrome verification of the data entered. Here is the signature and documentation for the function:
```cpp
bool is_palindrome(char *text)
```
Return `true` if `text` is a palindrome, `false` otherwise.
Turn in your commented program and a screenshot (`script`) of the execution run of the program. Include some sample tests in your captured code run. Examples of valid palindromes:
```
""
"a"
"aa"
"aaa"
"aba"
"abba"
"Taco cat"
"Madam, I'm Adam"
"A man, a plan, a canal: Panama"
"Doc, note: I dissent. A fast never prevents a fatness. I diet on cod."
```](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8cb58778-70ba-4f7e-90ce-7267bd79a013%2F95ecd4d8-c9e4-4454-9c33-8ceb7216946e%2Ft46eucq_processed.png&w=3840&q=75)
Transcribed Image Text:## Palindromes
A palindrome is a string that is identical to itself when reversed. For example, "madam", "dad", and "abba" are palindromes. Note: the empty string is a palindrome, as is every string of length one.
Write some code in the `main()` function to accomplish the following tasks:
- **Prompt for User Input**: Having written code to extract data from the keyboard (`stdin`) in Lab 3, reuse that code to prompt the user to enter a string between 0 and 255 characters in length. You should ignore whitespace and punctuation, and all comparisons should be case-insensitive.
- **Process User Input**: Process the entries from the keyboard and store them in the queue ADT provided in the lab 5 code package.
- **Check for Palindromes**: Use the `is_palindrome()` function ADT provided to implement a simple palindrome verification of the data entered. Here is the signature and documentation for the function:
```cpp
bool is_palindrome(char *text)
```
Return `true` if `text` is a palindrome, `false` otherwise.
Turn in your commented program and a screenshot (`script`) of the execution run of the program. Include some sample tests in your captured code run. Examples of valid palindromes:
```
""
"a"
"aa"
"aaa"
"aba"
"abba"
"Taco cat"
"Madam, I'm Adam"
"A man, a plan, a canal: Panama"
"Doc, note: I dissent. A fast never prevents a fatness. I diet on cod."
```
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education