Monday , December 18 2017
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

Also See:   Java program to implement polymorphism

Check Also

Java program to implement polymorphism

Java program to implement polymorphism: Polymorphism is a technique in java with which you can ...

Leave a Reply

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