Skip to content

Commit

Permalink
Merge pull request #191 from yujan1/yujan
Browse files Browse the repository at this point in the history
Zeros / Ones Pattern in Java
  • Loading branch information
dharmanshu9930 committed Oct 18, 2022
2 parents 7f22200 + 714dd52 commit 4dff47a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ZerosAndOnesPattern.java
@@ -0,0 +1,21 @@
import java.util.Scanner;

public class ZerosAndOnesPattern {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);

System.out.print("Enter the size of Row: ");
int row = scan.nextInt();

for (int i = 1; i <= row; i++) {
for (int j = 1; j <= i; j++) {
if (j % 2 == 0) {
System.out.print(0);
} else {
System.out.print(1);
}
}
System.out.println();
}
}
}

0 comments on commit 4dff47a

Please sign in to comment.