The application's output should look like the following:
Pattern A * ** *** **** ***** ****** ******* ******** ********* ********** Pattern B ********** ********* ******** ******* ****** ***** **** *** ** * Pattern C ********** ********* ******** ******* ****** ***** **** *** ** * Pattern D * ** *** **** ***** ****** ******* ******** ********* **********
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Patterns
{
class Program
{
static void Main(string[] args)
{
const int MAX_ROWS = 10;
Console.WriteLine("Pattern A\n");
for (int i = 1; i <= MAX_ROWS; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.WriteLine("\nPattern B\n");
for (int i = MAX_ROWS; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.WriteLine("\nPattern C\n");
for (int i = 1; i <=MAX_ROWS; i++)
{
for(int sp=i;sp>1;sp--)
{
Console.Write(" ");
}
for (int j = MAX_ROWS ; j >i; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.WriteLine("\nPattern D\n");
for (int i = 1; i <= MAX_ROWS; i++)
{
for (int sp = MAX_ROWS-1; sp>=i; sp--)
{
Console.Write(" ");
}
for (int j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Output:
Get Answers For Free
Most questions answered within 1 hours.