Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Must be in C. The program takes a linked list of words and counts the number of words that are all lowercase or all uppercase.

*Must be in C. The program takes a linked list of words and counts the number of words that are all lowercase or all uppercase. I will attach the code below. All that needs to be done is the function countSame.

#include #include #include #include

typedef struct words { char *name; struct words *next; } Words;

void print(Words *); Words *add(Words *, char *); int countSame(Words *);

int main(void) { char input[100]; Words *myList = NULL; printf("Enter a word : "); scanf("%s", input); while (strcmp(input, "xxx") != 0) { myList = add (myList, input); printf("Enter a word or 'xxx' to exit : "); scanf("%s", input); } printf(" The list is "); print(myList); printf(" "); printf(" countSame returns %d ", countSame(myList) ); return 0; } void print(Words *ptr) { while (ptr) { printf("%s ", ptr->name); ptr = ptr->next; } return; }

Words *add(Words *ptr, char *name) { Words *newNode = malloc( sizeof(Words) ); newNode->name = malloc( strlen(name) + 1 ); strcpy(newNode->name, name); newNode->next = ptr; return newNode; }

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

LO3 Name the seven categories of HR functions.

Answered: 1 week ago