Monday, January 12, 2026

Java Reverse Reducing Half Triangle pattern

 import java.util.Scanner;


class ReverseReducingHalfTriangle

{

static void reverseReducingHalfTriangle()

{

int height = 9;

//Run the outer for loop for 5 times, to print 5 rows.

for(int i = 0; i<5; i++)

{

//Reset height to 9 after each iteration of the inner loop.

height = 9;

//Run the inner for loop as many times as the value of 'i'.

for(int j = 0 ; j <= i ; j++)

{

//Print values from 9, reducing by 2 in each iteration. Number of iterations = 'i'.

System.out.print(height);

height -= 2;

}

//Introduce a new line after each iteration of the inner loop.

System.out.println();

}

}

public static void main(String[] args)

{

reverseReducingHalfTriangle();

}

}


Output:




No comments:

Post a Comment

47000 has 2 significant figures while 47000.000 has 8 significant figures...why? when both are the same value.

  Significant figures refer to the digits in a measured or calculated value that carry meaningful information about its precision .  They in...