Skip to content

Instantly share code, notes, and snippets.

@peterthorsteinson
Created October 2, 2019 23:06
Show Gist options
  • Save peterthorsteinson/e39f448ec2789f0c7009b1824c42333b to your computer and use it in GitHub Desktop.
Save peterthorsteinson/e39f448ec2789f0c7009b1824c42333b to your computer and use it in GitHub Desktop.
using System;
class MalloyPyramid
{
static void Main(string[] args)
{
Console.WriteLine("Enter a Number number under 100");
String rowCount = Console.ReadLine();
int rowNumber;
while (!int.TryParse(rowCount, out rowNumber))
{
Console.Write("Enter only whole numbers between 1 and 100.\n");
rowCount = Console.ReadLine();
}
for (int row = 0; row < rowNumber; row++)
{
for (int column = rowNumber; column > row; column--)
Console.Write(" ");
for (int column = 0; column < (2 * row + 1); column++)
Console.Write("*");
Console.WriteLine();
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment