DEV Community

Aashish Panchal
Aashish Panchal

Posted on

print 2 using C#

class Program
{
static void Main(string[] args)

    { 
        // 1
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 20; j++)
            {
                Console.Write("*");
                if (j == 20)
                    Console.Write("\n");
            }


        // 2
        for (int i = 1; i <= 3; i++)
        {
            for (int k = 1; k <= 13; k++) Console.Write(" ");

            for (int j = 1; j <= 7; j++)
            {
                Console.Write("*");
                if (j == 7)
                    Console.Write("\n");
            }
        }
        // 3
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 20; j++)
            {
                Console.Write("*");
                if (j == 20)
                    Console.Write("\n");
            }

        // 4
        for (int i = 1; i <= 3; i++)
        {
            //for (int k = 1; k <= 13; k++) Console.Write(" ");

            for (int j = 1; j <= 7; j++)
            {
                Console.Write("*");
                if (j == 7)
                    Console.Write("\n");
            }
        }

        // 5
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 20; j++)
            {
                Console.Write("*");
                if (j == 20)
                    Console.Write("\n");
            }
    }
}
Enter fullscreen mode Exit fullscreen mode

Output:-

********************
********************
********************
             *******
             *******
             *******
********************
********************
********************
*******
*******
*******
********************
********************
********************
Enter fullscreen mode Exit fullscreen mode

Top comments (0)