Pattern Programming in JAVA is nothing but simply playing with loop.

Here a simple program for you all to get some idea about it

PATTERN12.java

import java.io.*;
import java.util.*;
class PATTERN12
{
public static void main(String args[])
{
int i,j,n,m,k=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter Length”);
n=sc.nextInt();
for(i=0;i<n;i++)
{
for(j=n;j>i;j–)
{
System.out.print(” “);
}
for(j=0;j<i+1;j++)
{
System.out.print(“s “);
k=k+1;
}
System.out.print(“\n”);
}
System.out.print(“\n”);
System.out.print(“Count of s: – “+k);
}
}

for Reference

If any errors or issues mention in comment section.
Chandan Rajpurohit.

Leave a Reply