C# - How To Create A Program To Print Pyramid Stars In C#
In C# Programming Language.
Source Code:
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:
Pyramid In C# |