How to write C# Program to Print Star Triangle
First loop is for printing limit and second loop is for space , third loop is for printing star.
C# Program to print star triangle:
using System;
namespace MyApp
{
class triangle_class
{
static void Main(string[] args)
{
int number = 12;
for (int i = 1; i <= number; i++)
{
for (int j = 1; j <= number - i; j++)
Console.Write(" ");
for (int k = 1; k <= i; k++)
Console.Write(" *");
Console.WriteLine("");
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment