go to previous page   go to home page   go to next page

Answer:

  1. How should the loop be initialized?     Make the first character of the string the current character
  2. What should the loop condition test?     If the current character is null, end the loop
  3. What should be done for the next iteration?     Make next character in the string the current character.

Finished Loop

Loop of Capitalize Program

The flow chart is filled in with these choices. It is mostly pseudo-code not specifically tied to C.

Try to get the loop correct before you make any other design decisions. If the loop is correct, you can think about what the loop body should do with each small piece of the problem.

Now think about the body of the loop. It should deal with just one character.


QUESTION 4:

What should the loop body do?