Program to print modified Binary triangle pattern | Java implementation to print the modified binary triangle pattern ; Function to print the modified binary pattern ; Loop to traverse the rows ; Loop to traverse the numbers in each row ; Check if j is 1 or i In either case print 1 ; Else print 0 ; Change the cursor to next line after each row ; Driver Code ; Function call
import java . io . * ; class GFG { static void modifiedBinaryPattern ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( j == 1 j == i ) System . out . print ( 1 ) ; else System . out . print ( 0 ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 7 ; modifiedBinaryPattern ( n ) ; } }