July 28th, 2003, 10:42 AM
I am trying to develop a program to display like this
I worked out as
but not getting desired results
can anybody help me?
July 28th, 2003, 11:05 AM
This looks distinctly like homework, since I can't imaginea situation outside of a textbook where you'd want to do this. It's pretty simple though, and you'll probably only need two variables to pull it off.
First, you need an outer loop to count from your highest number down to 0. I actually defined a third variable called trigger to hold this highest number, but there's no reason to.
Now you need two loops inside of the outer loop.
The first one counts from 1 to the trigger value. If the inner loop value is less than or equal to the outer loop value, print the value of the inner loop, otherwise a space.
The second inner loop executes after the first inner loop. It counts from 1 less than the trigger value to 0. It uses the same printing conditions.
I won't give you the specific code, but I have tried this out and it works nicely.
Articles and commentary on web development