In this session, we will see how to Print Pyramid Pattern in C#. This is mostly asked interview question for the beginner.
Pyramid Pattern of Number in C#:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PyramidPattern { class Program { static void Main(string[] args) { int iRows = 6, iSpace, iNumber; Console.WriteLine("Pyramid Pattern"); for (int i = 1; i <= iRows; i++) // Total number of rows for pramid { for (iSpace = 1; iSpace <= (iRows - i); iSpace++) // Loop For Space Console.Write(" "); for (iNumber = 1; iNumber <= i; iNumber++) //increase the value Console.Write(iNumber); for (iNumber = (i - 1); iNumber >= 1; iNumber--) //decrease the value Console.Write(iNumber); Console.WriteLine(); } Console.ReadKey(); } } }
Output:
Pyramid Pattern of the asterisk in C#:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PyramidPattern { class Program { static void Main(string[] args) { int iRows = 6, iSpace, iNumber; Console.WriteLine("Pyramid Pattern"); for (int i = 1; i <= iRows; i++) // Total number of rows for pramid { for (iSpace = 1; iSpace <= (iRows - i); iSpace++) // Loop For Space Console.Write(" "); for (iNumber = 1; iNumber <= i; iNumber++) //increase the value Console.Write("*"); for (iNumber = (i - 1); iNumber >= 1; iNumber--) //decrease the value Console.Write("*"); Console.WriteLine(); } Console.ReadKey(); } } }
Output:
View More:
- C# Program to Print Fibonacci Series.
- C# Program to check whether a number is prime or not using Recursion.
- C# Program to find the sum of all item of an Integer Array.
- C# Program to find Largest Element in a Matrix.
Conclusion:
I hope would love this session. Please don’t hesitate to comment for any technical help. Your feedback and suggestion would be appreciated.
Thank You.
ed meds online med rx pharmacy canadian drug pharmacy
24 hour pharmacy drugstore near me discount pharmacy
best drugstore face wash pharmacy cheap online pharmacy drugstore
best drugstore shampoo canadian pharmacy reviews canadian online pharmacies
rx pharmacy coupons rx pharmacy canadian pharmacies
ed meds online best ed medication peoples pharmacy
What’s Happening i am new to this, I stumbled upon this I’ve discovered It absolutely helpful and it has aided me out loads. I hope to contribute & assist different customers like its helped me. Great job.|
Excellent beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea|