Finish count(s): count how many letters (upper or lower case), spaces, digits and other characters are in the string, and show the four numbers in that order. For "abc XYZ 2024 #1!": 6 letters, 3 spaces, 5 digits, 2 others (# and !), so it shows 6 3 5 2. The program counts two strings.
6 3 5 2 2 6 3 4
#include <stdio.h>
void count(const char *s) {
int letters = 0, spaces = 0, digits = 0, others = 0;
for (int i = 0; s[i] != '\0'; i++) {
char c = s[i];
// your code here: find which type c is and add 1 to that count
}
printf("%d %d %d %d\n", letters, spaces, digits, others);
}
int main(void) {
count("abc XYZ 2024 #1!");
count("x = 3 * y + 42;");
return 0;
}
Run tries the examples. When they look right, Submit.