im a newbie in c#

well, our professor asked us to:
Write a program in c# to print a triangle composed of a symbol. The number of of lines in the triangle and the symbol should be entered as an input from a user.

Example:

Enter the number of lines: 7
Please choose a symbol: #
Output:
       #
     ###
    ####
   #####
  ######
 #######
########

something like that..
Please.. I really need help..
thank you!

Attachments c#.JPG 59.51 KB

Hi Ms. LizR,

well, so far i only got the first part.. where the user can enter the symbol they want & the number of lines..

thats about it..
im confused..

thanks ms Lizr..

Ok but how are you confused?
You have a number, you know how many lines for your triangle you need to show.

What bit are you confused on? If you want to say "all of it" to this, Id suggest a chat with your professor as you clearly cant have understood what he would have told you - its not uncommon for things to seem to make sense till you come to do them, but he needs to know you dont understand.

No ones gonna write it for you, guiide you, make suggestions, but so far

I suggest you start out with writing down your process on paper - use plain english or pseudocode or something but write it down. Then try to break it down into manageable chunks. If you're stuck on one part then work on another piece. Get as much of it together as possible and then we maybe we can guide you from there.

Think about what sections you are working on and that might help. For instance if you're text is on loops, then you want to loop through the number of times printing out your symbol on each line the number of times you are in the loop (if you are in position 1 then you print 1 of them, then the loop increments to 2 and you print 2 of them and so on until you reach the number equal to what was input)

I'm not sure where you are in your text, but your guide is probably based on what you've read so far.

Without giving the answer, you will need to print lineCount number of lines. If you loop and print say lineCount number of '*' starting with lineCount being 10 and you count down to 0 you would get the following

*
**
***
****
*****
******
*******
********
*********
**********

This is not what your thumbnail looks like

**
        ****
       ******
      ********
     **********
    ************
   **************
  ****************
 ******************
********************

Notice this is lineCount 10 and printSymbol '*'

If lineCount 3 and printSymbol '-'

--
 ----
------

This post gives you more than enough to figure it out.

Ask yourself this as well : "is there a maximum or a minimum amount of lines that should be looked for?"

If you are getting hung up on the functions to use, search the Internet for C# console output and C# looping.

This article has been dead for over six months. Start a new discussion instead.