Print pyramid shape by numbers between 1 to 9 in C#

Hello friends, try below code for printing Pyramid shape by any numbers between 1 to 9.


E.g. If number=4, print pyramid shape as below:

          1
        21 
      321
    4321 

    public class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter any number between 1 to 9 : ");
            int num = Convert.ToInt32(Console.ReadLine());

            for (int i = 1; i <= num; i++)
            {
                //printing space
                for (int j = i; j <= num - 1; j++)
                    Console.Write(" ");

                    int s = i;
                    for (int k = 0; k < i; k++)
                    {
                        //printing numbers
                        Console.Write(s--);
                    }
                    Console.WriteLine();
              }

            Console.ReadLine();
        }

Please leave your comments.

Comments

  1. At Coepd (Center of Excellence for Professional Development) we practice Object-Oriented Programming concepts and mentor .Net Platform, C#.NET, ADO.NET which helps the attendees to build database-driven Web applications and Web Sites successfully. We also guide the attendees to develop web-based enterprise applications using ASP.NET and Visual Studio which comforts in developing the Web Services using .Net framework in Service-oriented Architecture. The Internship Program Also covers Frontend design technologies HTML, HTML5, CSS, CSS3, XML, Bootstrap, JQuery, Angular JS, and AJAX. Our collaborative ecosystem comprising of Partnerships with Software Companies enables real time software development life cycle experience.

    https://coepd.com/DotnetTraining.html

    ReplyDelete
  2. very informative blog and useful article thank you for sharing with us , keep posting
    Dot NET Online Course Hyderabad

    ReplyDelete
  3. Hello guys and girls, please give me an honest feedback about the website:http://under-the-open-sky.com and any suggestions of what could be done to make it better. http://under-the-open-sky.com. Any thoughts? It would be great to hear your opinions/suggestions about it.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to start a free blog with Blogger in simple steps

How to verify/add a blogger blog in Google Webmaster Tool or Search Console. How to verify your site's ownership.

Structs in C#