On understanding how to do this work, without an if statement:
Let's give this job an analogy, and see if that helps.
Let's say I gave you nine cards, and said "Your job is to turn over each card in the order I gave them to you, on the table".
You wouldn't need an if statement in your thought processes. Because I gave you the cards (the letter for Fantastic), in the right order, and I told you there were 9 cards, (Fantastic has 9 letters), plus I told you where I wanted you to place them (print them out).
If you have nine things to do (or a hundred things, no difference), you just have to do 9 (or a hundred) things - start counting! :)
So no if statement is needed. It's alright to have an extra if statement, however. It is *not* alright to have a lot of unnecessary if statements in your code, however.
The indentation looks **MUCH** better. The while word should be indented equal to the lines above it, but the whole code is 100% more readable, already.
Now go play with this. What if I wanted every vowel of Fantastic, printed out, but not the consonants? What if I wanted Fantastic printed out backwards? What if you were asked to print out one letter from Fantastic, so each letter was on it's own line?
F
a
n
t
etc.
What if you wanted to print out the word, in a column just three char's wide?
Fan
tas
tic
?
Could you print out the word, picket fence style?
Now do it all over again, using a call to another function to actually do the printing, instead of having it done by main. :)Code:F n a t c
a t s i
These kinds of drills, and play and challenges, will all help build your programming "muscles".