series-10

1

1 0

1 0 1

1 0 1 0

 class series

{

public static void main(String args[])

{

for(int r=1;r<=4;r++)

{

for (int c=1 ; c<=r ; c++)

{

if(c%2==0)

System.out.print(0+ "  ");

else

System.out.print(1+" ");

}

System.out.println() // to come to next line

}

}

}

//Common way

class series

{

public static void main(String args[])

{

int d=1;  // how many element in first line

for(int r=1;r<=4;r++)

{

for (int c=1 ; c<=d ; c++)

{

if(c%2==0)

System.out.print(0+ "  ");

else

System.out.print(1+" ");

}

d++;

System.out.println() // to come to next line

}

}

}


Comments

Post a Comment

Popular posts from this blog