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

Answer:

See below.


for loop

Here is (yet another) translation of the flowchart into C;

#include <stdio.h>
#include <ctype.h>

void main( void )
{
  int j;     /* index to current char */
  char sample = "But, soft! what light through yonder window breaks?"

  /* while current char is not null */
  for ( j=0; sample[j]; j++ )  
  {
    putchar( toupper( sample[j] );
  }
}

You may be thinking that structured programming is massive over-kill for such a simple program. Most experienced C programmers would almost immediately write this code without much thought. They would not draw a flowchart.

But structured programming is still going on. If you are learning programming thinking about structure with easy programs is good practice for the hard design problems to come.


QUESTION 8:

Is this a practical program?