A Floyd’s triangle is a right angular array of natural numbers starts with 1. It start from top left corner with 1 and print in increment order. Follow is a C# program to print a Floyd’s triangle.
Program:
using System;
public class Program
{
public static void Main()
{
int n=1;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
Console.Write(n+' ');
n++;
}
Console.WriteLine(' ');
}
}
}
Output:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Taking input from user for number of row in triangle.
Program:
using System;
public class Program
{
public static void Main()
{
int n,num=1;
Console.WriteLine('Enter the number of row in Floyd's triangle');
n=int.Parse(Console.ReadLine());
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
Console.Write(num+' ');
num++;
}
Console.WriteLine(' ');
}
}
}
Output:
Enter the number of row in Floyd's triangle
5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Floyd’s triangle:
A Floyd’s triangle is a right angular array of natural numbers starts with 1. It start from top left corner with 1 and print in increment order. Follow is a C# program to print a Floyd’s triangle.
Program:
Output:
Taking input from user for number of row in triangle.
Program:
Output: