Computer Science, asked by Anonymous, 4 months ago

Write a program to print the Floyd's triangle[Given below]
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

no spams quality answer required:)

Answers

Answered by Itzraisingstar
20

\bold{Answer:}

import java.util.Scanner;

class Pattern 3

{

    static void Floyd Triangle()

    {

         int c,d,num=1;

         for(c=1;c<=5;c++)

         {

                for(d=1;d<=c;d++)

                 {

                          system.out.print(num+"");

                          num ++;

                 }

                 System.out.println();

         }

    }

}  

Answered by kochedaksh06
2

Answer:

/* Program: It Prints Floyd's triangle based on user inputs

* Written by: Chaitanya from beginnersbook.com

* Input: Number of rows

* output: floyd's triangle*/

import java.util.Scanner;

class FloydTriangleExample

{

public static void main(String args[])

{

int rows, number = 1, counter, j;

//To get the user's input

Scanner input = new Scanner(System.in);

System.out.println("Enter the number of rows for floyd's triangle:");

//Copying user input into an integer variable named rows

rows = input.nextInt();

System.out.println("Floyd's triangle");

System.out.println("****************");

for ( counter = 1 ; counter <= rows ; counter bbye++ )

{

for ( j = 1 ; j <= counter ; j++ )

{

System.out.print(number+" ");

//Incrementing the number value

number++;

}

//For new line

System.out.println();

}

}

}

Explanation:

Output:

Enter the number of rows for floyd's triangle:

6

Floyd's triangle

****************

1

2 3

4 5 6

7 8 9 10

11 12 13 14 15

16 17 18 19 20 21

Here it is which you want

and thanks for following me

Similar questions