# Left angle triangle – Java Program to Print Left Angled Triangle Number Pattern

## Program to Print Left Angled Triangle Number Pattern

Left angle triangle: In the previous article, we have discussed Java Program to Print Right Angled Triangle with Row wise Decreasing Number Pattern
In this article we will see how to print left angled triangle number pattern.

Example-1

When size value=5

5
54
543
5432
54321
Example-2:

When size value=4

4
43
432
4321

Now, let’s see the actual program to print it.

Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example guide and practice well.

Approach:

• Enter total size and number store them in integer variables size.
• Take one outer for loop to iterate the rows,
• Take 1st inner for loop to print spaces .
• Take 2nd inner for loop to print column value .
• After each iteration print a newline.

### Java Code to Print Left Angled Triangle Number Pattern

import java.util.Scanner;
class Main
{
public static void main(String[] args)
{
// taking size of no. of iteration
//Row and column are the iterators
int size , numberOfRows , numberOfColumns;
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.print("Enter the number of rows : ");
size = scanner.nextInt();
//Outer loop to iterate the rows
//Iterates from size  to 1
for ( numberOfRows = size; numberOfRows >=1 ; numberOfRows--)
{
//Inner loop to iterate the columns
//Iterates from  1 to row value
for (  numberOfColumns = 1; numberOfColumns < numberOfRows ; numberOfColumns++)
System.out.print(" ");
for (  numberOfColumns = size ; numberOfColumns >= numberOfRows ; numberOfColumns--)
System.out.print(numberOfColumns);
// printing in new line
System.out.println();
}
}
}


Output :

Enter the number of rows : 5

5
54
543
5432
54321

### C Code to Print Left Angled Triangle Number Pattern

#include <stdio.h>
#include <stdlib.h>
int main()
{
int size , numberOfRows , numberOfColumns;
printf("Enter the number of rows : ");
scanf ("%d",&size);
for ( numberOfRows = size; numberOfRows >=1 ; numberOfRows--)
{
for (  numberOfColumns = 1; numberOfColumns < numberOfRows ; numberOfColumns++)
printf(" ");
for (  numberOfColumns = size ; numberOfColumns >= numberOfRows ; numberOfColumns--)
printf("%d",numberOfColumns);
printf("\n");
}
return 0;
}


Output :

Enter the number of rows : 5

5
54
543
5432
54321

### C++ Code to Print Left Angled Triangle Number Pattern

#include <bits/stdc++.h>
using namespace std;
int main()
{

int size , numberOfRows , numberOfColumns;
printf("Enter the number of rows : ");
scanf ("%d",&size);
for ( numberOfRows = size; numberOfRows >=1 ; numberOfRows--)
{
for (  numberOfColumns = 1; numberOfColumns < numberOfRows ; numberOfColumns++)
cout << " ";
for (  numberOfColumns = size ; numberOfColumns >= numberOfRows ; numberOfColumns--)
cout << numberOfColumns;
cout << "\n";
}
return 0;
}

Output :

Enter the number of rows : 5

5
54
543
5432
54321

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Number Pattern Programs: