Class A{
public static void main(String []args){
int row=5;
int space=row-1;
int value=1;
for (int i = 0; i < row; i++) {
for (int j = 0; j < value; j++) {
if(j%2==0){
System.out.print("1 ");
}else if(j%2==1){
System.out.print("0 ");
}
}
System.out.println("");
value=value+2;
}
}
Labels:
IT JOBS
public static void main(String []args){
int row=5;
int space=row-1;
int value=1;
for (int i = 0; i < row; i++) {
for (int j = 0; j < value; j++) {
if(j%2==0){
System.out.print("1 ");
}else if(j%2==1){
System.out.print("0 ");
}
}
System.out.println("");
value=value+2;
}
}
Responses
0 Respones to "Java program to print 1 101 10101"
Post a Comment