C# Star Pattern (9) |
/* C# program to print the following pattern * * * * * * * * * * * * * * * * */ namespace Patterns { class Program { static void Main(string[] args) { int i, j; for (i = 1; i <= 5; i++) { for (j = 5; j > i; j--) { Console.Write(" "); } Console.Write("*"); for (j = 1; j < (i - 1) * 2; j++) { Console.Write(" "); } if (i == 1) Console.WriteLine(); else Console.WriteLine("*"); } for (i = 4; i >= 1; i--) { for (j = 5; j > i; j--) { Console.Write(" "); } Console.Write("*"); for (j = 1; j < (i - 1) * 2; j++) { Console.Write(" "); } if (i == 1) Console.WriteLine(); else Console.WriteLine("*"); } } } }