How to print an isosceles triangle
- by Steve
Hello,
I'm trying to learn programming by myself, I'm working from a book that has the following problem which I can't solve:
Allow the user to input two values: a character to be used for printing an isosceles triangle and the size of the peak for the triangle. For example, if the user inputs # for the character and 6 for the peak, you should produce the following display:
#
##
###
####
#####
######
#####
####
###
##
#
This is the code I've got so far:
char character;
int peak;
InputValues(out character, out peak);
for (int row = 1; row < peak * 2; row++)
{
for (int col = 1; col <= row; col++)
{
Console.Write(character);
}
Console.WriteLine();
}
Console.Read() // hold console open
Thanks in advance.