Consider the following declarations: typedef struct Node { struct Node *next; ch
ID: 3718096 • Letter: C
Question
Consider the following declarations:
typedef struct Node { struct Node *next; char *text; } Node; typedef struct { Node *start; Node *end; } List;
Write a function called listCase to determine (1) the total number of lowercase characters, and (2) the total number of uppercase characters in the text stored in the list. Do not break this down per node; rather, count all lowercase and uppercase characters across all nodes.
Your function should return nothing, and take three parameters: • A pointer to List. • Two pointers to integers, called lower and upper, to export the results.
There should be no input or output, and your function should not modify the list.
Explanation / Answer
#include<iostream>
#include<ctype.h>
void listCase(List *s, int *lower, int *upper){
Node *p;
p = s->start;
*lower = 0;
*upper = 0;
while ( p != NULL){
char *q = p->text;
for (int i = 0; i<strlen(p->text); i++){
if (isupper(*(q+i)))
*upper++;
if (islower(*(q+i)))
*lower++;
}
p = p->next;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.