Design an algorithm and show it in either pseudocode or a flow chart (you only n
ID: 3823084 • Letter: D
Question
Design an algorithm and show it in either pseudocode or a flow chart (you only need to do one) for the following problem. For this question, read in a series of words (one at a time, in a loop), until EOF, and keep track of how many words are read in. For each word, print out the word and the number of its position in the input data only if the word is not equal to "sunny". For example, the fourth word (if it is not equal to "sunny") will be printed out along with the number 4. Each occurrence of "sunny" will be not be printed, but numbering will continue. For example, if the input looked like this:Explanation / Answer
The pseudocode is stated below
CountWords(file f)
{
i = 0;
while(not EOF(f)), do
w = getnextword(f);
i = i + 1;
if (w != "sunny")
display(i,w);
end-while
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.