Re: Program help

From: rossum (rossum48_at_coldmail.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 22:46:54 +0100

On 14 Sep 2004 20:50:01 -0700, tool540@yahoo.com (Josh) wrote:

>Howdy
> i am newb somewhat to programing and i was just for fun trying to
>compile a program that asks the user for an odd int less than 22 and
>then returns this
>*****************
>******* *********
>****** ********
>***** *******
>etc. the first line reps. the number enterd by user
>but i am having trouble i can get the first line but am having trouble
>making the white space in the middle i am using a nested loop. Should
>i use arrays? Any help would help thanks
>Josh

As others have said you will generally get a better response to what
looks like a homework question if you post your own code. You were
very lucky to get Karl's reply - his advice is excellent.

You say that you can do the first line, but are having trouble with
the other lines. Think of the other lines in three parts: stars,
spaces, stars. You will need to work out how many of each you need on
each line, you have some pointers to this already. Hint the number of
spaces is given by the original number minus the total number of stars
on the line.

Since you can do the first line, you should be able to do the two
"stars" parts of the other lines, they are just shorter versions of
the first line. Indeed since you will be repeating basically the same
code you should probably put it into its own function (assuming you
have done functions that is). Something like: void stars(int num).
If you can do that, then you should be able to modify it to make a
second function that prints spaces: void spaces(int num). Test each
of these separately, and when they are both working correctly you can
use them in your final program.

rossum

--
The ultimate truth is that there is no Ultimate Truth


Relevant Pages

  • Re: Thrill Of A Lifetime!
    ... I was just teasing, Helen. ... I don't always go to the trouble of adding a smiley, ...  Movie stars. ...
    (rec.sport.golf)
  • Super Mario DS help anyone?
    ... I have 22 stars in Super Mario 64 DS. ... having trouble on... ... I picked up a DS last year around this time with Mario ... 64ds and I never really got into this game (guess I kept buying a new ...
    (rec.games.video.nintendo)
  • Re: Consumer Fireworks from around the World
    ... Flash with some rice size stars or maybe coarse ... Ti flake? ... "When in trouble, when in doubt - Run in circles, scream and shout!" ...
    (rec.pyrotechnics)
  • Re: Calling Alan Hopes bluff
    ... Trouble is, not everyone would and so you'd still see the content in ... other people's replies. ... Shoot the stars with a lemonade ray gun. ...
    (uk.media.tv.misc)