How to printing 1 232 34543 in triangle in c#.
In this article, we will learn how to display 1 232 34543 in triangle below pattern in c#.
Sample Solution
C# Sharp Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int loop, c, num, no; Console.Write("Enter Number -> "); no = Convert.ToInt32(Console.ReadLine()); for (loop = 1; loop <= no; loop++) { num = loop; for (c = 1; c <= no - loop; c++) { Console.Write(" "); } for (c = 1; c <= loop; c++) { Console.Write(num); num++; } num--; num--; for (c = 1; c < loop; c++) { Console.Write(num); num--; } Console.WriteLine("\t"); } Console.ReadLine(); } } }
Sample Output
No comments:
Post a Comment