Pattern -4
Logic---
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
if(j%2==0)
{
System.out.print("0 ");
}
else
System.out.print("1 ");
}
System.out.println( );
}
Program--
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
class Pattern4
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
if(j%2==0)
{
System.out.print("0 ");
}
else
System.out.print("1 ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
No comments:
Post a Comment