How to print a right-angled triangle with stars (*) in C#

1 Answer

0 votes
using System;

public class RightAngledTriangleFromStarts_CSharp
{
	public static void print_right_angled_triangle_from_starts(int n) {
	    for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                Console.Write("*");
            }
            Console.WriteLine();
        }
	}
	
	public static void Main(string[] args)
	{
		int n = 7;
 
        print_right_angled_triangle_from_starts(n);
    }
}



/*
run:
       
*
**
***
****
*****
******
*******
    
*/


answered Apr 8, 2014 by avibootz
edited Sep 14, 2024 by avibootz

Related questions

1 answer 103 views
1 answer 115 views
1 answer 234 views
1 answer 173 views
...