Saturday 12 November 2011

How to Print Star in C#

Write the program in C# for print the
                  *
                 **
                ***
               ****
              *****
----------------------------------------
the program is ..
using System;


    class Class1
    {

        static void Main()
        {

            Console.WriteLine("Enter the value for print  the star ");

            int k = int.Parse(Console.ReadLine());

            int n = k - 1;

            int x = 2 * n + 1;

            for (int p = 0; p <= n; p++)
            {

                for (int j = k - 1; j >= 0; j--)
                {

                    Console.Write(" ");

                }

                for (int i = 0; i <= (x - 2 * (k - 1)); i++)
                {

                    if (i % 2 == 1)
                    {

                        Console.Write("*");

                    }

                    else
                    {

                        Console.Write(" ");

                    }

                }

                Console.WriteLine();

                k--;

            }

            Console.ReadLine();

        }

    }
Hope this will help you
Thanks
ROHIT SRIVASTVA




5 comments:

  1. Hi Rohit Ji plz send Me Some asp.net programs plz friend......yor programing is great !!
    my id is nrmlsharma31@gmail.com
    Nirmal Sharma

    ReplyDelete
  2. Which type of program you want please let me know

    ReplyDelete
  3. rohit i m new for asp.net, can u guide me, i need ur email for any query

    ReplyDelete
  4. hii shashi my email id is rrohit_0087@yahoo.co.in
    any issue related with ASP .net , Jquery

    ReplyDelete
  5. hi rohit,

    I hav a search.aspx page to search and display name of all employees stored in sql database by the first alphabate of their make....

    pls help me out.....

    ReplyDelete