[Courses] Chapter 4 Exercise 4-2 SPOILER
Wendy Galovich
wendy at scottishmusician.com
Sun Feb 17 20:03:07 EST 2002
On Sunday 17 February 2002 20:53, Mary wrote:
>
> With regard to the program above, by the way, try and adapt it so that
> it can accept ANY two numbers (x and y, say) as input and print out an x
> by y block, without recompiling. Being able to write routines that don't
> need to be thrown out and rewritten when your boss/co-worker/self walks
> along and says, "er, I wanted a 6 by 9 block" is one of the key ideas of
> programming.
>
> -Mary.
I agree - I'm holding that thought, and will try it when I've progressed far
enough with the more basic concepts (still learning the C "alphabet"!)
But just to check on my understanding... If I assign three variables:
char a; /* the character which will be printed */
int x; /* number of times "a" will be printed across a row */
int y; /* number of rows to print */
then I can use a loop referencing y to control the number of times the row is
printed? Also, in order to print the block for different x and y variables,
without recompiling, the input values need to come from outside of the
program itself (from the keyboard or an input file), correct?
Wendy
More information about the Courses
mailing list