Computer Science, asked by usksss847, 9 months ago

Print the pattern in Java.
101010
01010
1010
010
10
0

please quickly answer​

Answers

Answered by Anonymous
2

Answer:enter the numbers of rows on your own

Explanation:

Hey you how can I write the whole program

Here.

import java.util.Scanner

class Binarypattern4{

public static void main(String args[]){

int i,j,rows;

int count=1;

Scanner scan=new Scanner(System.in);

System.out.print("Enter the number of rows: ");

rows=scan.nextInt();

for(i=1; i<=rows; i++){

for(j=1; j<=i; j++){

if(j%2==1){

System.out.print("1");

}

else{

System.out.print("0");

}

}

System.out.println();

}

}

}

Answered by harshkum2004
0

Explanation:

public class pattern

{

public static void main (String args[])

{

int i j;

for ( i=1;i<=6;i++)

{

for (j=i;j>=1;j++)

{

if (i%2==0 && j%2==0)

System.out.print("1");

else if(i%2!=0 & & j%2!=0)

System.out.print("1");

else

System.out.print("0");

}

System.out.primtln();

}

}

}

Similar questions