Write a program in C# Sharp to display the pattern like pyramid using an asterisk and each row contain an odd number of an asterisks
using System; class PyramidPattern { static void Main(string[] args) { int rows = 5; // Change this to desired number of rows for (int i = 1; i <= rows; i++) { // Print spaces before asterisks for (int j = 1; j <= rows - i; j++) { Console.Write(" "); } // Print asterisks for (int k = 1; k <= 2 * i - 1; k++) { Console.Write("*"); } Console.WriteLine(); // Move to next line } } }
Write a program in C# Sharp to display the pattern like pyramid using an asterisk and each row contain an odd number of an asterisks
Reviewed by Bhaumik Patel
on
7:34 PM
Rating: