Pattern programs are nothing but patterns consisting of numbers, alphabets or symbols in a particular form. These kinds of pattern programs can be solved easily using for loop condition.


Program 1:-
package forloop;
public class Ascending {
public static void main(String[] args)
{
int count;
for(count=1; count<=5; count++)
{
for(int i=1; i<=5; i++)
{
System.out.print(i+" ");
}
System.out.println();
}
}
}
Output Screenshot:-

Program 2:-
package forloop;
public class Decending {
public static void main(String[] args)
{ int count;
for(count=1; count<=5; count++)
{
for(int i=5; i>0; i--)
{
System.out.print(i+" ");
}
System.out.println();
}
}
}
Output Screenshot:-

Program 3:-
package forloop;
public class Verical1 {
public static void main(String[] args)
{
int rows=5;
int coln=5;
for(int i=1; i<=rows; i++)
{
for(int j=1; j<=coln; j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
Output Screenshot:-

Program 4:-
package forloop;
public class Rvertical {
public static void main(String[] args)
{
int rows=5;
int coln=5;
for(int i=5; i>0; i--)
{
for(int j=5; j>0; j--)
{
System.out.print(i);
}
System.out.println();
}
}
}
Output Screenshot:-

Program 5:-
package forloop;
public class Star {
public static void main(String[] args)
{
int count;
for(count=1; count<=5; count++)
{
for(int i=1; i<=5; i++)
{
System.out.print("*"+ " ");
}
System.out.println();
}
}
}
Output Screenshot:-
