Put your arrays and strings knowledge to work! You'll build a program that reads a sentence and reports back useful statistics about its contents.
YOUR TASK
Write a C program that reads a sentence (one line) and prints:
The total number of characters (excluding the newline)
The number of words (sequences separated by spaces)
The number of vowels (a, e, i, o, u — upper and lower)
Need a hint?
Step-by-step:
1. Use fgets(str, 200, stdin); to read a full line
2. Loop through each character with strlen() from <string.h>
3. Count characters — subtract 1 if the last char is '\n'
4. Count words: increment when you hit a space after a non-space
5. Check vowels with a series of || comparisons or strchr("aeiouAEIOU", c)
6. Print each result on its own line
Example (input: "Hello World"):
Characters: 11
Words: 2
Vowels: 3
Code Editor
Ready
Output
Console
Console initialized...
Ready for Project 1: Word Statistics Analyzer
> Test your code with the "Check My Code" button
> When it passes, the Complete button will unlock!