0% found this document useful (0 votes)
8 views10 pages

pattern programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

pattern programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

/*

Question?

97531

7531

531

31

*/

class pattern

public static void main()

for(int i=9; i>=1; i-=2)

for(int j=i; j>=1; j-=2)

System.out.print(j);

System.out.println();

}
/*

Question?

11

9 11

7 9 11

5 7 9 11

3 5 7 9 11

1 3 5 7 9 11

*/

class patternA

public static void main()

for(int i=11; i>=1; i-=2)

for(int j=i; j<=11; j+=2)

System.out.print(j+" ");

System.out.println();

}
/*

33

333

3333

33333

*/

class patternB

public static void main()

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

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

System.out.print("3");

System.out.println();

}
/*

#1

#22

#333

#4444

#55555

*/

class patternC

public static void main()

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

System.out.print("#");

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

System.out.print(i);

System.out.println();

}
/*

98

987

9876

98765

987654

9876543

*/

class patternD

public static void main()

for(int i=9; i>=3; i-=1)

for(int j=9; j>=i; j-=1)

System.out.print(j+" ");

System.out.println();

}
/*

AB

ABC

ABCD

ABCDE

ABCDEF

*/

class patternE

public static void main()

for(int i=65; i<=70; i++)

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

System.out.print((char)j+" ");

System.out.println();

}
/*

DE

DEF

DEFG

DEFGH

*/

class patternF

public static void main()

for(int i=68; i<=72; i++)

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

System.out.print((char)j+" ");

System.out.println();

}
/*

10

101

1010

*/

class patternG

public static void main()

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

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

if(j%2==0)

System.out.print("0");

else

System.out.print("1");

System.out.println();

}
/*

01

010

0101

*/

class patternH

public static void main()

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

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

if(j%2==0)

System.out.print("1");

else

System.out.print("0");

System.out.println();

}
/*

01

010

1010

*/

class patternI

public static void main()

int a=0, b=0;

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

a=b;

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

if(a%2==0)

System.out.print("1");

else

System.out.print("0");

a++;

} b++;

System.out.println();

}}

You might also like