Pages

Thursday, August 28, 2014

Java Program for Floyd's triangle


Program:-

class Floyd {
public static void main(String args[]) {
int num = 1, c, d;
System.out.println("Floyd's triangle :-");
for (c = 1; c <= 4; c++) {
for (d = 1; d <= c; d++) {
System.out.print(num + " ");
num++;
}
System.out.println();
}
}
}


Output:


Floyd's triangle :-
1
2 3
4 5 6
7 8 9 10

No comments:

Post a Comment