Home / Blue J / java program for pattern with indentation

java program for pattern with indentation

 java program for pattern making
     1
    21
   321
  4321

 

This is a simple java program for pattern with indentation.
Indentation in pattern is thus required. This can be done using extra for loop to provide the required indentation per line.
class format3
{
public static void main(String arg[])
{
int i,j,k=1;            //section of code to be implemented in any of Java/ bluej/ c/c++
for(i=1;i<5;i++)
{
for(j=5;j>=i;j--)    // for loop to print the spaces/indentation required for every line before the values required
System.out.print(' ');

for(j=i;j>0;j--)    // after spacing , vales are to be printed
System.out.print(j);

System.out.println();
}
}
}

OUTPUT:

Tags: program for pattern making in bluej, java program for pattern making, c program for pattern / formats.

Also See:   C program for Quick Sort

Check Also

How to find inverse of a matrix in C programming?

In order to find inverse of a matrix in C programming, you need to know ...

Leave a Reply

Your email address will not be published. Required fields are marked *