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

Answer:

The pieces of the problem are the individual characters in the string.


Grain Size

Universal Flowchart

Often you need to carefully study a problem to find the right size pieces. The right size is sometimes called the grain size of a problem. If you pick the right grain size, the problem fits naturally into the flow chart.

In practice you would use a C library function to do this. But let us say that you do not have such a function. In this case, your code should iterate over the string, character by character.

For a loop, three things need to be done

  1. Initialization
  2. Testing a condition
  3. Preparing for the next iteration

QUESTION 3:

What three things should be done for our loop?

  1. Initialization    
  2. Testing a condition      
  3. Preparing for the next iteration

Think in terms of the characters in the string. Recall that we are working with a null-terminated string.