Output:
Click Here For Java Online Compiler
Solution:
Enter the number of rows: 5 1 10 101 1010 10101
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; class BinaryTriangle { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of rows: "); int base = scanner.nextInt(); for (int a = 1; a <= base; a++) { for (int c = 1; c <= a; c++) { if (c % 2 == 0) { System.out.print("0"); } else { System.out.print("1"); } } System.out.println(); } } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon