Question: *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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!