java program for printing binary right angled traingle
/*
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
*/
import java.io.*;
import java.util.*;
public class Binary_triangle {
public static void main(String[] args) {
int num,row,coloumn;
System.out.println("Enter the size of row");
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
for(row=1;row<num;row++)
{
for(coloumn=1;coloumn<=row;coloumn++)
System.out.print(coloumn % 2+"\t");
System.out.print("\n");
}
}
}
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
*/
import java.io.*;
import java.util.*;
public class Binary_triangle {
public static void main(String[] args) {
int num,row,coloumn;
System.out.println("Enter the size of row");
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
for(row=1;row<num;row++)
{
for(coloumn=1;coloumn<=row;coloumn++)
System.out.print(coloumn % 2+"\t");
System.out.print("\n");
}
}
}
Comments
Post a Comment