Floyd's triangle

Java code to reverse order triangle number patterns

Java code to reverse order triangle number patterns

In this tutorial, we will discuss Java code to reverse order triangle number patterns. We will see some reverse Floyd’s triangle number patterns, using nested for loop.

Floyd’s triangle number pattern

Pattern program 1

Floyd’s triangle reserved pattern
import java.util.Scanner; 
public class RevNum_pattern1{
public static void main(String args[]){
Scanner sc=new Scanner(System.in); //Scanner class in java
System.out.print("Enter the rows you want");
int rows=sc.nextInt();
System.out.println("");

for (int i=1; i<=rows; i++){
  for (int j=i; j>=1; j--){
  
   System.out.print(j);

}
System.out.println();

}
}
}

When the above code is executed, it produces the following results:

Enter the rows you want :8
1
21
321
4321
54321
654321
7654321
87654321

In this Floyd’s triangle pattern, numbers are arranged to reverse order in every line – used nested for loop

Pattern program 2

 

floyd’s triangle pattern 2

 

import java.util.Scanner; 
public class RevNum_pattern2{
public static void main(String args[]){
Scanner sc=new Scanner(System.in); //Scanner class in java
System.out.print("Enter the number of rows you want");
int rows=sc.nextInt();
System.out.println("");

while(rows>=1){
    int j=rows;
    while(j>=1){
        System.out.print(j);
        j--;
    }
    rows--;
    System.out.println();
}


}
}

When the above code is executed, it produces the following results:

Enter the number of rows you want:6
654321
54321
4321
321
21
1

 

Pattern program 3

 

Floyd’s triangle reserved pattern
import java.util.Scanner; 
public class RevNum_pattern3{
public static void main(String args[]){
Scanner sc=new Scanner(System.in); //Scanner class in java
System.out.print("Enter the number of rows you want");
int rows=sc.nextInt();
System.out.println("");

while(rows>=1){
    int j=8;
    while(j>=rows){
        System.out.print(j);
        j--;
    }
    rows--;
    System.out.println();
}


}
}

When the above code is executed, it produces the following results:

Enter the number of rows you want: 8
8
87
876
8765
87654
876543
8765432
87654321

Pattern program 4

 

Reverse number pattern
import java.util.Scanner; 
public class RevNum_pattern4{
public static void main(String args[]){
Scanner sc=new Scanner(System.in); //Scanner class in java
System.out.print("Enter the rows you want :");
int rows=sc.nextInt();
System.out.println("");

while(rows>0){
for (int i=1; i<=rows; i++){
  
   System.out.print(rows);
}
System.out.println(" ");
rows--;
        }
     }
}

 

When the above code is executed, it produces the following results:

Enter the rows you want: 9
999999999
88888888
7777777
666666
55555
4444
333
22
1

 

Similar post

Floyd’s triangle number pattern using for loop in C

Floyd’s triangle pattern using nested for loop in Java

Floyd’s triangle pattern using nested while loop in Java

Hollow pyramid triangle pattern in C++ language

Pyramid star pattern in Cpp

Pyramid star pattern in C

Pyramid star pattern in Java 

Rhombus pattern in Java using for loop

Rhombus pattern in C using while loop

Rhombus pattern in C++ using do-while loop

 

Suggested for you

for loop in Java

while loop in Java

for loop in C language

while loop in C language

while loop in cpp language

For loop in Cpp language

Nested for loop in C++ language

Nested for loop in Java language

Nested for  loop in C language

Nested for loop in Python language

 

 

 

CPP program to print Floyd's triangle number patterns
C program to pyramid number pattern
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago