Star patterns program in C#

This console program show how to print star pattern in C# like triangle patterns.

Source code - Star patterns program in Console(C#).


    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace starpatterns
    {
        class Program
        {
            static void Main(string[] args)
            {
               int value = 5;
               int i, j, k;
               Console.WriteLine("PRINTING THE STAR.");
               for (i = 1; i <= value; i++)
               {
                  for (j = 1; j <= value-i; j++)
                  { 
                  }
                  for (k = 1; k <= i; k++)
                  {
                      Console.Write("*");
                  }
                  Console.WriteLine("");
               }
               Console.ReadLine();
            }
        }
    }	
	

Output

	
   PRINTING THE STAR.
   *
   * *
   * * *
   * * * *
   * * * * *
           
Advertisement here

Share this Page.