Day-44:Pattern Program
Notes1: package Pattern; public class Training { public static void main(String[] args) { for(int end = 1; end

Notes1:
package Pattern;
public class Training {
public static void main(String[] args) {
for(int end = 1; end<=5; end++)
{
for(int col = 1; col<=end; col++) //1 2
{
System.out.print(col+" ");
}
System.out.println();
}
}
}
output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Notes2:
package Pattern;
public class Training2 {
public static void main(String[] args) {
for(int end = 5; end>=1; end--)
{
for(int col = 1; col<=end; col++)
System.out.print(col + " ");
System.out.println();
}
}
}
output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Notes3:
package Pattern;
public class Training3 {
public static void main(String[] args) {
for(int end = 1; end<=5; end++)
{
for(int col = 1; col<=end; col++)
System.out.print(end+" ");
System.out.println();
}
}
}
output:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Notes4:
package Pattern;
public class Training4 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1 ; col<=6-row; col++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
output:
- *
Notes5:
package Pattern;
public class Training5 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(col +" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Notes6:
package Pattern;
public class Training6 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
Notes7:
package Pattern;
public class Training7 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(col*row +" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
1 2 3 4 5
2 4 6 8
3 6 9
4 8
5
notes8:
package Pattern;
public class Training8 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6
notes9:
package Pattern;
public class Training9 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(row+col-1+" ");
}
System.out.println();
}
}
}
output:
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
Notes10:
package Pattern;
public class Training10 {
public static void main(String[] args) {
for(int row=1; row<=5; row++)
{
for(int col= 1; col<=6-row; col++)
{
System.out.print(6-col+" "); // 1 2 3 4 5
}
System.out.println();
}
}
}
output:
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5