by Dinesh Thakur Category: Control Structures

Algorithm for Floyd Triangle:

step 1: Set a= 1

step 2: Read row

step 3: Initialize i=0

step 4: Repeat through step-12 until i less than row

step 5: Initialize j=0

step 6: Repeat through step-10 until j less than or equals to i

step 7: Print a

step 8: If a less than 10 then print “ “

Else print “ “

step 9: a=a+1

step 10: j= j+ 1

step 11: move to new line

step 12: i=i+ 1

step 13: Exit

Here is the Java Example for Floyd Triangle:

import java.util.Scanner;

public class FloydTriangle
                public static void main(String ar[])
                    int a=1,i,j,row;
               Scanner s1=new Scanner(;
               System.out.println("Enter The Number of ROWS");
                    for(j=0;j<=i ;j++)
                           System.out.print(a+" ");
                           System.out.print(a+" ");

Floyd Triangle in Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles