Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeros / Ones Pattern in Java #191

Merged
merged 1 commit into from Oct 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}
}
}