
Write a 'for' statment that will print Floyd's traingle.

Hi Friend,
Try the following code:
public class FloydTriangleExample {
public static void main(String[] args) throws Exception {
int k=0;
System.out.println();
for(int i = 0; i <5; i++){
for(int j = 0; j <i; j++){
k = k + 1;
System.out.print(k);
System.out.print(" ");
}
System.out.println("");
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.