Reputation: 129
Meaning words with characters in alphabetical order. It reads these words from a notepad file, with one on each line. I've written the code for it, but I can't figure out why it won't work. I compare the characters in a for loop, but the boolean value I use stays as I initialize it and does not change. Below is my code, I'td be great if someone could tell me what I'm doing wrong.
The extra variables are for keeping track of the average and total number of words. I left out the variable initialization for the sake of readability. If I initialize test as true, the program prints every word, but if I initialize it as false the program just ends.
Upvotes: 0
Views: 79
Reputation: 68715
One problem in your code is that your for
loop condition seems to be reversed. Change this:
for (n=0; n>theWord.length() -1; n++)
to
for (n=0; n < theWord.length() -1; n++)
Upvotes: 0
Reputation: 6480
for (n=0; n>theWord.length() -1; n++)
Should be
for (n=0; n < theWord.length() -1; n++)
Upvotes: 1