Write a Program for Printing the Stars

input : number of Rows

Output

         *
      *  *
   *  *  *
*  *  *  *
Code
        public static void PrintStar(int rows)
        {
        int temp=rows;
            for (int i = 1; i <= rows; i++)
            {
                for (int spacecounter = temp; spacecounter >= 1; spacecounter--)
                {
                    Console.Write("   ");
                }

                for (int starCounter = 1; starCounter <= i; starCounter++)
                {
                    Console.Write(" * ");
                }
                temp=temp-1;
                Console.WriteLine("");
            }
        }

Write the program to Print Star

Write the program to implement
*****
***
*
***
*****

 

public static void Star1(int n)
    {

      int k = n;
      int temp = n;
      Console.WriteLine();
      while (n > 0)
      {
        for (int i = 0; i < k; i++)
        {
          Console.Write("*");
        }
        
        Console.WriteLine();
        n = n - 1;
        if (n > temp / 2)
        {
          k = k - 2;
        }
        else
        {
          k = k + 2;
        }

      }
    }
 
This program will work for odd values of n