;

C# Program To Print A Full Pyramid


Tutorialsrack 02/08/2019 C# Programs

In this C# program, we will learn how to write a program to print a full pyramid.

Here is the Code of Program to print a full pyramid:

Code - C# Program To Print A Full Pyramid
using System;

namespace TutorialsrackPrograms
{
    class Program
    {
        //Program to print a full pyramid
        static void Main(string[] args)
        {
            int a = 0;
            int b = 0;
            int c = 0;
            int l = 1; int rows = 0;

            Console.Write("Enter number of rows:\t");
            rows = Convert.ToInt16(Console.ReadLine());

            for (a = 1; a <= rows; a++)
            {
                for (b = 10; b >= a; b--)
                {
                    Console.Write(" ");
                }

                for (c = 1; c <= l; c++)
                {
                    Console.Write("*");
                }
                l = l + 2;
                Console.WriteLine();
            }

            Console.Read();

        }
    }
}
Output

Enter the number of rows: 10
                  *
                ***
              *****
            *******
          *********
        ***********
      *************
    ***************
  *****************
*******************


Related Posts



Comments

Recent Posts
Tags