Home / Blue J / java program for pattern #14

java program for pattern #14

	1
	01
	101
	0101
	10101

This is an easy to implement pattern but the quality of a programmer depends on the way they implement their algorithm. How much can you reduce your coding. So here is how you can code this pattern without using if statement.

Also see: Alternate c program for pattern#14

class pattern
{ 
 public static void main(String args[])
{
int i,j,calc;
for(i=1;i<=5;i++)
{
 	for(j=0;j<i;j++)
 	{ 
	calc=(i+j)%2;
	System.out.print(calc); 
	}
 	System.out.println();
} 
} 
}

OUTPUT:

pattern#14

Check Also

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which ...

Leave a Reply

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

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.