Increasing Number Triangle Starting from 11 in C#

What You’ll Learn
How to print a triangle where each row prints values computed from the row and column indices using 9 + i + j.
⭐ Pattern Output
For rows = 5, the pattern looks like this:
Output
11
12 13
13 14 15
14 15 16 17
15 16 17 18 191
Complete C# Program
This matches the reference program: for each row i, print j = 1..i values of (9 + i + j).
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
Console.Write((9 + i + j) + " ");
Console.WriteLine();
}
}
}
}2
Variation — Custom base and rows
Let the user choose rows and the base value instead of hardcoding 9:
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter base: ");
int baseVal = Convert.ToInt32(Console.ReadLine());
if (rows < 1) return;
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
Console.Write((baseVal + i + j) + " ");
Console.WriteLine();
}
}
}
}12 people found this page helpful
