Computer Science Download the template program palindrome.c and the input data file data11.txt. Fill out the function palindrome() to determine if the passed string is a palindrome (a string that reads the same forward and backward). Return 1 from the function if it was passed a palindrome and 0 otherwise. Fill out the function newPalindrome() to allocate an instance of the given Palindrome structure and return it

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Computer Science

Download the template program palindrome.c and the input data file data11.txt. Fill out the function palindrome() to determine if the passed string is a palindrome (a string that reads the same forward and backward). Return 1 from the function if it was passed a palindrome and 0 otherwise. Fill out the function newPalindrome() to allocate an instance of the given Palindrome structure and return it. Fill out the delPalindrome() function to free an instance of the Palindrome structure. Fill out the main program to read the data11.txt file from stdin. It has one word per line. Test each input to determine if it is a palindrome. If it is, save it in a new Palindrome instance, and chain it in a list of palindromes. At the end display a palindrome count, a line count, and the list of palindromes. The two output lines should look like (with the missing counts and palindromes filled in):

 

There are __ palindromes in the ____ line input file

anna, ... , aga

 

Don't forget to free the allocated storage at the end of the program. There is a class to delPalindromes() just for that purpose.

 

#include<stdio.h>

 

#include<string.h>

 

#include<stdlib.h>

 

#define WORDSZ 30

 

int palindrome(char *_line) {

 

/* your code goes here */

 

return _pal; // return 1 if a palindrome, 0 otherwise

 

}

 

typedef struct Palindrome {

 

char *word;

 

struct Palindrome *link;

 

} Palindrome;

 

Palindrome *newPalindrome(char *pal) {

 

Palindrome *nwp;

 

/* your code goes here */

 

}

 

void delPalindrome(Palindrome *pal) {

 

/* your code goes here */

 

}

 

void delPalindromes(Palindrome *pal) {

 

Palindrome *nxt;

 

/* your code goes here */

 

}

 

int main(int argc, char *argv[]) {

 

int ct;

 

int pct;

 

char word[WORDSZ];

 

Palindrome *palList, *pal;

 

ct = 0;

 

pct = 0;

 

palList = 0;

 

while (0 <= scanf("%s", word))

 

{

 

/* your code goes here */

 

}

 

printf("There are %d palindromes in the %d line input file\n", pct, ct);

 

if (pct > 0)

 

{

 

/* your code goes here */

 

}

 

delPalindromes(palList);

 

return 0;

 

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY