PATTERN 1 :-
import java.util.Scanner;class WORPS
{
public static void main()
{
System.out.println("Enter Any Word :");
Scanner sc=new Scanner(System.in);
String s;
s=sc.next();
char ch1;
int d=s.length();
for(int i=d-1;i>=0;i--)
{
for(int j=0;j<=i;j++)
{
ch1=s.charAt(j);
System.out.print(ch1+" ");
}
System.out.println();
}
}
}
PATTERN 2 :-
import java.util.Scanner;public class WORPS1
{
public static void main()
{
for (int i = 5; i >= 1; i--)
{
int n = 5;
for (int j = 0; j<= n - i; j++)
{
System.out.print(" ");
}
for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
System.out.println();
}
}
}
Original Post : https://sarthakmunds3.blogspot.com/2020/01/java-pattern-programs.html
No comments:
Post a Comment