wap in java to print the Floyd's triangle
Answers
Answered by
6
- Write a program to print the Floyd's Triangle.
Floyd's Triangle looks something like this.
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
So, here is the code,
import java.util.*;
class Pattern
{
public static void main(String s[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows for the pattern. ");
int n=sc.nextInt(), a=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
System.out.print(a++ +" ");
System.out.println();
}
}// end of main()
}// end of class.
Similar questions