Nested For Loop isosceles triangle HELP.

Hello,

I am just a beginner in programming, i'm just in my first year so i dont know many things in C++.. My professor gave us a project that will create an isosceles triangle that measures 5 in its two sides and 9 for the base.. I tried searching but still i cannot do the program, we are only allowed to use nested for loop.. this should be the output..

    #
   # # 
  #   #
 #     #
#########


Please help me. :(
Can you do it all (ignoring the requirement to use loops)?

If you can, do so. Once you've done it by yourself, you ought to see at least one pattern emerge. Of course, if someone else does it for you, you won't see it.

Then you can try to use the pattern improve your program.
I dont have any knowledge in looping.. i dont have any clue on doing this.. :( i tried searching and trying.. but its just go in a straight like this

#
#
#
#
#
#
#

Can you do it all (ignoring the requirement to use loops)?
we are only allowed to use nested for loop...


make basic counter before first loop.
use setw (counter);
counter shall indicate how many whitespacess will be there for each output line
counter shal be then for each for loop something like setw (counter -= (counter / 2)) for each nested for lopp
that will reduce how many whitespaces are between # # #
than next line # # # # and so on.


AND use break to stop cout between first # and last # in current line
for example
1
2
for (short i = 0; i < 6; i++) 
     if (i <= 2 ) break

to enshure u cout only 2 of # in current line

AND FOR last line skip that rule using if statement too to cout full line of ####### where setw (counter = 0);
Last edited on
Topic archived. No new replies allowed.