class

**PatternDemo**

{

public static void main(String s[])

{

int n = 5;

for(int i=1;i<=n;i++)

{

for(int j=0;j<i;j++)

{

System.out.print((i+j)%2+"\t");

}

System.out.print("\n");

}

}

}

Output:

1

0 1

1 0 1

0 1 0 1

1 0 1 0 1

class

**PatternDemo**

{

public static void main(String s[])

{

int n = 4,k=0;

for(int i=0;i<n;i++)

{

for(int j=0;j<=i;j++)

{

System.out.print((k++)+"\t");

}

System.out.print("\n");

}

}

}

Output:

0

1 2

3 4 5

6 7 8 9

Great Article

ReplyDeleteThanks for IT the

ReplyDeletenic one Mr.Patel Patel ...keep updating codes with easy and efficient code...

ReplyDeleteThanks krushna akhade

DeleteNice program HARDCODER(Sir SOHAM PATEL)

ReplyDeleteThanks Prathamesh Agare

Delete