Question bank › Strings
Dsa Strings Warm-up

Count the Number of Words

Develop a function that counts the number of words in a given string. Words are defined as sequences of characters separated by whitespace. The input will be a single line. The output should be a single integer representing the word count. Example input: This is an example. Example output: 4

Key concepts

stringscountingwords

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.