← Back to Strings
Question 48
Count A Chosen Letter
Count A Chosen Letter
Read a word and then a single letter, count how many times that letter appears in the word by comparing each character with it in a for loop, and print the result in the form <letter> appears <count> times. Input: two lines, the word then the letter, no prompts. A letter that never appears prints a count of 0.
Expected Output:
s appears 4 times= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Strings
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.