public class pattern3
{
public static void main(String[] args)
{
int i,j,k;
for(i=1; i<5;i++)
{
System.out.print("\n");
for(j=1; j<=i; j++)
{
k=j%2;
if(k==0)
System.out.print("0");
else
System.out.print("1");
}
}
}
}
output:
1
10
101
1010
{
public static void main(String[] args)
{
int i,j,k;
for(i=1; i<5;i++)
{
System.out.print("\n");
for(j=1; j<=i; j++)
{
k=j%2;
if(k==0)
System.out.print("0");
else
System.out.print("1");
}
}
}
}
output:
1
10
101
1010
No comments:
Post a Comment
SAY HELLO!!