Pattern program in java
Q.1 Write a program then print the following pattern as bellow.
12345
12345
12345
12345
12345
public class Sibani
{
public static void main(String args[])
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=5;c++)
{
System.out.print(+c);
}
System.out.println();
}
}
}
Q.2 Write a program then print the following pattern as bellow.
54321
54321
54321
54321
54321
class SIbani1
{
public static void main(String args[])
{
int r,c;
for(r=5;r>=1;r--)
{
for(c=5;c>=1;c--)
{
System.out.print(+c);
}
System.out.println();
}
}
}
Q.3.Write a program then print the following pattern as bellow.
1
12
123
1234
12345
class Sibani2
{
public static void main(String args[])
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(+c);
}
System.out.println();
}
}
}
Q.4.Write a program then print the following pattern as bellow.
12345
1234
123
12
1
class Sibani3
{
public static void main(String args[])
{
int r,c;
for(r=5;r>=1;r--)
{
for(c=1;c<=r;c++)
{
System.out.print(+c);
}
System.out.println();
}
}
}
Q.5.Write a program then print the following pattern as bellow.
11111
22222
33333
44444
55555
class Sibani4
{
public static void main(String args[])
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=5;c++)
{
System.out.print(+r);
}
System.out.println();
}
}
}