Jump to content
xisto Community
tigershubham

Print Triangle In C# simple c# program print triangle

Recommended Posts

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace csharp{    class Program    {        static void Main(string[] args)        {            bool m = true;            while (m == true)            {                Console.WriteLine("Enter the number");                int n = Convert.ToInt32(Console.ReadLine());                for (int i = 1; i <= n; i++)                {                    int j;                    for (int s = 1; s <= i - 1; s++)                    {                        Console.Write(" ");                    }                    for (j = i; j <= n; j++)                    {                        Console.Write("" + j);                    }                    for (int k = j - 2; k >= i; k--)                    {                        Console.Write("" + k);                    }                    Console.WriteLine("");                }                Console.ReadLine();                Console.WriteLine("Continue (True/False)");                m = Convert.ToBoolean(Console.ReadLine());            }        }    }}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.