Program 5: Triangle Pattern
Explanation:
This program prints a triangle of a given width using the entered number.
C# Code:
using System;
class Program
{
static void Main()
{
[Link]("Enter a number: ");
int number = 6; // Test Data
[Link]("Enter the desired width: ");
int width = 6; // Test Data
for (int i = 1; i <= width; i++)
{
for (int j = 1; j <= i; j++)
{
[Link](number + " ");
}
[Link]();
}
}
}
Expected Output:
6
6 6
6 6 6
6 6 6 6
6 6 6 6 6
6 6 6 6 6 6