triangle print

This is a discussion on triangle print within the C Programming forums, part of the General Programming Boards category; Code: Hi all Code: , I'm just starting out with c language , I would ask all of you the ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    1

    triangle print

    Code:
    Hi all
    Code:
    ,
    
    I'mjust starting out withclanguage,I wouldask all of youthe followinghelp:
    
    *
    **
    ***
    ****
    *****
    
    
    Howcan I makethe following program?
    
    Itried to solvein thisway tounderstandhow to useloops:
    
    first of allI didcreate a columnlike this:
    
    for (column=1;column <=5;column+ +){
    printf("*");
    printf("n");
    
    }
    to achievea column.
    
    Nowhowdo I getthe rowsthat particularcolumn?
    
    
    Waiting for reply
    

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    because you need to print line by line, you can't write one column then go back and fill in the next. you need to write a complete row at a time. so have an outer loop for rows. then an inner loop for columns where you use the row number to tell you how many start to print for the current row.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    You could repost your question WITHOUT all the extra formatting you seem to have added.

    [COLOR=#333333 ][FONT=arial ][CODE ]
    Hi all[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ],[/FONT ][/COLOR ]

    [COLOR=#333333 ][FONT=arial ]I'm[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]just starting out with[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]c[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]language[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ],[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]I would[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]ask all of you[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]the following[/FONT ][/COLOR ][COLOR=#333333 ][FONT=arial ]help:[/FONT ][/COLOR ]


    The only tags you need are [code][/code], and those go not surprisingly around actual code.
    The rest should just be pure text as you would type it (or copy and pasted from a text editor).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 02-19-2010, 07:50 PM
  2. triangle help??
    By unix7777 in forum C++ Programming
    Replies: 6
    Last Post: 11-09-2008, 03:46 PM
  3. YangHui triangle print test prog?
    By toysoldier in forum C++ Programming
    Replies: 8
    Last Post: 08-20-2004, 09:46 AM
  4. Replies: 0
    Last Post: 03-28-2003, 08:20 AM
  5. triangle
    By volk in forum C Programming
    Replies: 2
    Last Post: 01-06-2003, 05:05 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21