Wednesday 19 August 2015

Write a program special Star Triangle using C#.Net


Program:


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

namespace ConsoleApplication1
{
    class specialprogram
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the value:");
            int x = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= x; i++)
            {
                for (int j = 1; j <= x - i; j++)
                {
                    Console.Write(" ");
                }
                for (int k = 1; k <= 2 * i - 1; k++)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("*");
                    Thread.Sleep(100);
                }
                Console.WriteLine();
            }
        }
    }
}

output:



No comments:

Post a Comment