C# - How To Create A Star Pyramid In C#

C# - How To Create A Program To Print Pyramid Stars In C#

                                                                                                                                                     

In This C# Code We Will See How To Make A Program To Print A Pyramid Using For Loop
In C# Programming Language.

Source Code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
             int v = 20;//the number of spaces
        
        //20 = how many lines
        for(int i = 1; i <= 20; i++)
        {
            //loop to print spaces
            for(int j = 1; j < v; j++)
            {
                Console.Write(" ");
            }
            
            v = v-1;
            //loop to print stars
                for(int t = 1; t < i*2; t++)
                {
                  Console.Write("*");  
                }
            //create a new Line
                Console.WriteLine();
        }
        
            Console.ReadLine();
        }
    }
}
OUTPUT:
Star Pyramid Program In C#
Pyramid In C#


Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer