Write a class FloydExample3 to display the output as below using control structures enter the value of Floyd triangle 4

0

Assignment: Module 03- Part 02

Write a class FloydExample3 to display the output as below using control structures enter the value of Floyd triangle 4

Write a class FloydExample3 to display the output as below using control structures enter the value of Floyd triangle 4

Output:

01 

010 

0101

Here is the Java code to display the output as described:

import java.util.Scanner;

public class FloydExample3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the value of Floyd triangle: ");
        int n = sc.nextInt();
        sc.close();
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("0");
            }
            System.out.println();
        }
    }
} 

And here is the output for n = 4:

Enter the value of Floyd triangle: 4

0
01
010
0101 

👉Write a program FloydExample3 to display the output as below using control structures👈

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates