Re: Program help
From: rossum (rossum48_at_coldmail.com)
Date: 09/15/04
- Next message: John Harrison: "Re: Returning arrays and Objects in C++"
- Previous message: Alan Mackenzie: "Re: Searching for a C++ code browser which will...."
- In reply to: Josh: "Program help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: John Harrison: "Re: Returning arrays and Objects in C++"
- Previous message: Alan Mackenzie: "Re: Searching for a C++ code browser which will...."
- In reply to: Josh: "Program help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|