Exercise 10 bug/oversight?


#1

I’m going through Exercise 10 in the C book, and I just noticed what might be a bug in the code. The ‘y’ case has code to handle the letter starting from index 2. But no code exists in that case block to handle Y either at index 0 or 1, thus resulting in no printing. For example, running with “yes” prints
1: ‘E’
2: s is not a vowel.

Is this intentional or a bug?

My personal fix was an else clause as follows

if (i > 2) {
<tab>// the original code here
} else {
<tab>printf("%d: %c is not a vowel in this position.\n", i, letter);
}

If it was intentional, what led to this choice?


#2

Look at the Study Drills.