;

C# Program To Print A Half Pyramid


Tutorialsrack 02/08/2019 C# Programs

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

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

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

namespace TutorialsrackPrograms
{
    class Program
    {
        //Program to print a Half pyramid
        static void Main(string[] args)
        {
            int a, b, rows;

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

            for (a = 1; a <= rows; a++)
            {
                for (b = 1; b <= a; b++)
                {
                    Console.Write("* ");
                }
                Console.WriteLine();
            }

            Console.Read();
        }
    }
}
Output

Enter the number of rows: 10

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *


Related Posts



Comments

Recent Posts
Tags