Ready to begin
Choose Next step to follow the actual course records.
CountVowelsAndConsonants(X) receives one word card. For “reluctant”, start i = 1, Vcount = 0 and Ccount = 0. Inspect the ith letter. If it is a vowel, increase Vcount; ELSE increase Ccount. Then increase i outside both branches.

Trace the records, compare the methods and watch what changes. Back and Reset let you try again.
Ready
Choose Next step to follow the actual course records.
Start with Next step. Predict what changes before reading the explanation.
Procedure CountVowelsAndConsonants(X):
Letters = alphabetic letters of X.Word
i = 1
Vcount = 0
Ccount = 0
while i <= number of Letters:
if lowercase(Letters[i]) is one of a, e, i, o, u:
Vcount = Vcount + 1
else:
Ccount = Ccount + 1
i = i + 1
return (Vcount, Ccount)
End Procedure| i | Letter | Branch | Vcount | Ccount |
|---|---|---|---|---|
| 1 | r | ELSE | 0 | 1 |
| 2 | e | IF | 1 | 1 |
| 3 | l | ELSE | 1 | 2 |
| 4 | u | IF | 2 | 2 |
| 5 | c | ELSE | 2 | 3 |
| 6 | t | ELSE | 2 | 4 |
| 7 | a | IF | 3 | 4 |
| 8 | n | ELSE | 3 | 5 |
| 9 | t | ELSE | 3 | 6 |
| 10 | No letter | Loop stops | 3 | 6 |
The tutorial’s word has no punctuation and uses the stored LetterCount as the loop limit. To let you try cards like “cane...” and “fire-eyed”, this explorer makes a letters-only sequence first and ignores punctuation and hyphens. It uses the five-vowel convention a/e/i/o/u, so y is counted as a consonant here. This extension is stated explicitly; punctuation is not treated as a consonant.
The loop condition uses ≤, so the ninth letter is processed. After the final update, i becomes 10 and the test fails. At every step, Vcount + Ccount equals the number of letters already processed. The procedure returns two values in order: (vowels, consonants). The caller can store them as (V, C) = CountVowelsAndConsonants(X).
What goes wrong if i increases only inside the vowel branch?
At the first consonant, i would stay unchanged. The loop would keep processing the same letter forever. Increase i after either branch.
Why does i < 9 miss information for reluctant?
It stops before position 9, so the final t is skipped. Use i ≤ 9 for 1-based positions.
What is returned for reluctant, and what does 6 represent?
(3, 6): 3 vowels and 6 consonants. Return order is part of the procedure contract.
What is returned for cane... in the letters-only explorer?
(2, 2). The letters are c, a, n, e. Dots are ignored rather than counted as consonants.