printing star in v flag shape in c#


printing star in v flag shape in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace star_flag
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j,n;
            Console.WriteLine("Enter no for printing star in flag shape");
            n = int.Parse(Console.ReadLine());
            for (i = 1; i <= n; i++)
            {
                for (j = 1; j <= i; j++)
                {
                    Console.Write("*");
                }
                for (j = n; j >= i; j--)
                {
                    Console.Write(" ");
                }
                 for (j = n-1; j >= i; j--)
                {
                    Console.Write(" ");
                }
                for (j = 1; j <= i; j++)
                {
                    Console.Write("*");
                }
                    Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}

output

Enter no for printing star in flag shape
6
*           *
**         **
***       ***
****     ****
*****   *****
****** ******

Comments