Friday, 15 March 2013

Print Square Between Stars

Print Square Between The Stars:



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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 12, i, j;
            for (i = 1; i <= n; i++)
            {
                for (j = n; j >=i ; j--)
                {
                    Console.Write("*");
                }
                for (int k = 1; k <=i-1; k++)
                {
                    Console.Write("  "); //Two Sapces.
                }
                    for (j = n; j >= i; j--)
                    {
                        Console.Write("*");
                    }
                Console.WriteLine();
            }
            for (i = 1; i <= n; i++)
            {
                for (j = 1; j <= i; j++)
                {
                    Console.Write("*");
                }
                for (int k = n-1; k >=i; k--)
                {
                    Console.Write("  "); // Two Spaces
                }
                for (j = 1; j <= i; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            Console.ReadLine();

        }
    }
}

No comments:

Post a Comment