Programming Examples

Java program to print floyds triangle


Write a program to print Floyd's triangle as shown below:

1

2  3

4  5  6

7  8  9  10

11 12 13 14 15

Solution

class Floyd
{
    public static void main(String arr[])
    {
        int a,b,c=1;
        for(a=1;a<=5;a++)
        {
            for(b=1;b<=a;b++)
            {
                System.out.print(c+"  ");
                c++;
            }
            System.out.println();
        }
    }
}
Output

1  

2  3  

4  5  6  

7  8  9  10  

11  12  13  14  15  

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad