Knowledge Garden

Search

Search IconIcon to open search

Create a Pyramid in CSharp

Last updated Feb 9, 2024 Edit Source

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
using System;
					
public class Program
{
	public static void Main()
	{
        Console.Write("Enter the number of rows for the pyramid: ");
        int numRows = int.Parse(Console.ReadLine());

        for (int i = 1; i <= numRows; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                Console.Write(i);
            }
            Console.WriteLine();
        }
	}
}
1
2
3
4
5
6
Enter the number of rows for the pyramid: **5**  
1  
22  
333  
4444  
55555