Blogger Tutorial,C,C++,Java,Python Programming, Notes & Questions,Answers of Programming available in this blog.
For Visit Main Blog of this Blog : Click Here

Breaking

Thursday, 2 January 2020

JAVA Pattern Programs || WORPS Khariar Exam

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();
    }
}
}
JAVA Pattern Programs

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();
        }
   }
}
JAVA Pattern Programs || WORPS Khariar
Original Post : https://sarthakmunds3.blogspot.com/2020/01/java-pattern-programs.html

No comments:

Post a Comment