Computer Science, asked by ronaldo2169, 5 months ago

wap in java to print the Floyd's triangle​

Answers

Answered by anindyaadhikari13
6

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program to print the Floyd's Triangle.

\star\:\:\:\sf\large\underline\blue{Code:-}

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