Saturday, 23 January 2016

PatternDemo in Java - II


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

8 comments:

  1. Replies
    1. Great Article android based projects

      Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. nic one Mr.Patel Patel ...keep updating codes with easy and efficient code...

    ReplyDelete
  3. Nice program HARDCODER(Sir SOHAM PATEL)

    ReplyDelete
  4. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete