In: Computer Science
Create a C# Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the last two patterns. There should be no other output statements in the application, other than labeling each pattern.
The application's output should look like the following:
Pattern A
*
**
***
****
*****
******
*******
********
*********
**********
Pattern B
**********
*********
********
*******
******
*****
****
***
**
*
Pattern C
**********
 *********
  ********
   *******
    ******
     *****
      ****
       ***
        **
         *
Pattern D
         *
        **
       ***
      ****
     *****
    ******
   *******
  ********
 *********
**********
Here is the solution,
// your code starts here
using System;
using System.Globalization;
namespace patterns
{
class Program
{
static void Main(string[] args)
{
// for pattern A
Console.WriteLine("Pattern A");
for (int i=1; i<=10; i++)
{
for(int j=1; j<=i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
// for pattern B
Console.WriteLine("Pattern B");
for (int i = 10; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
// for pattern C
Console.WriteLine("Pattern C");
for (int i = 10; i >= 1; i--)
{
for(int j=i; j <= 9; j++)
{
Console.Write(" ");
}
  
for (int j = 1; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
// for pattern D
Console.WriteLine("Pattern D");
for (int i = 1; i <= 10; i++)
{
for (int j = i; j <= 10; j++)
{
Console.Write(" ");
}
for (int j = 1; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
}
}
}
// code ends here

here is the screenshot of the code:-


Thank You.