Write a program to print the Floyd's Triangle?
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
import java.util.*; class FloydTriangle { public static void main(String[] args) { Scanner scannerInput=new Scanner(System.in); System.out.println("Enter how rows you want"); int rows=scannerInput.nextInt(); int num=1; for(int index=0;index<rows;index++) { int repeat=index; while(repeat>=0) { System.out.print(num+" "); num++; repeat--; } System.out.println("\n"); } }}
Enter how rows you want 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
good one keep it on and post more logical programmes if u have
ReplyDelete