Java
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();
}
}
}
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();
}
}
}
JAVA Pattern Programs || WORPS Khariar Exam
02 January
0
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();
}
}
}
Must Read :-
Previous article
Next article
Leave Comments
Post a Comment