Java program to display triangle 0 10 101 0101

```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /* Display Triangle as follow 0 1 0 1 0 1 0 1 0 1 */ class Output2{ public static void main(String args[]){ for(int i=1;i<=4;i++){ for(int j=1;j<=i;j++){ System.out.print(((i+j)%2)+" "); } System.out.print("\n"); } } }```

27 Responses to “Java program to display triangle 0 10 101 0101”

1. very FALTU PROGRAM TERI MAA KA SAKINAKA…………

2. the correct output is:
0
1 0
0 1 0
1 0 1 0

3. /* The correct way to get exact output
0
1 0
1 0 1
0 1 0 1 */

public class triangle_0_10_101_0101 {
public static void main(String[] args) {
int n=12,a=0;
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
a=n%2;
System.out.print(a +" ");
n–;
}
System.out.println();
}
}
}

4. babloo kumar

0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5

5. kirit chavda

1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

i want this pyramid program

• public class HelloWorld{

public static void main(String []args){
for(int i=4;i>=1;i–){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println("");
}
for(int i=1;i<=4;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println("");
}
}
}

6. Sourabh Jain

import java.util.Scanner; public class pattern3 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.print(“enter the number of rows: “); Scanner sc = new Scanner(System.in); int s= sc.nextInt(); int temp=s; for(int j=1;j=1;i–) { System.out.print(“*”); } temp–; System.out.println(); } for(int l=2;l<=s;l++) { for(int k=1;k<=l;k++) { System.out.print("*"); } System.out.println(); } }}

7. class pat{
void xy(){
for(int i=10;i>=1;i–)
{
for(int a=1;a<=i;a++)
{System.out.print(" ");}
for(int b=1;b<=10-i;b++)
{System.out.print((b%2)+" ");}
System.out.println( );}}}

try this