1
10
101
1010
10101
public class Pattern
{
public static void main(String args[])
{
int i,j;
System.out.println("The pattern");
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(j%2==0)
System.out.print("0"+" ");
else
System.out.print("1"+" ");
}
System.out.println();
}
}
}
No comments:
Post a Comment