#include <stdio.h> #include <string.h> #include <ctype.h> int main() { int n; char words[15][101]; // Array to store up to 15 words of max length 100 characters char letter; int count = 0; scanf("%d", &n); // Input each word into the array for (int i = 0; i < n; ++i) { scanf("%s", words[i]); } // Input the letter to check scanf(" %c", &letter); // Convert letter to lowercase (if it's uppercase) letter = tolower(letter); // Count words that start with the specified letter for (int i = 0; i < n; ++i) { if (words[i][0] == letter) { count++; } } printf("%d\n", count); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter