🌙 DARK

Top Pattern Program in Java


 Pattern Program in java alphabet pattern, Number pattern Program.


Write a program to print the Alphabet pattern.

Input Format:

Input consists of a single integer which corresponds to the number of rows..

Output Format:

Refer sample output.


Sample Input:

5


Sample Output:

E

ED

EDC

EDCB

EDCBA

 

 @MRProgrammer89 



CREATE CLASS < Main :


package Mr_Programmer;

import java.util.Scanner;

public class Main {

       public static void main(String[] args) {

             Scanner sc = new Scanner(System.in);

             int alphabet = 90;

             System.out.print("Enter no: ");

             int a = sc.nextInt();

            

             for(int i =1; i<=a; i++) {

                    for(int j =1; j<=i; j++){

                           System.out.print((char) (alphabet - j-(25-a)) + " ");

                    }

                    System.out.println();

             }

       }

}




Write a program to print the given Number pattern.


Input Format:

Input consists of a single integer.

Output Format:

Refer sample outputs. There is a trailing space at the end of each line.

 

Sample Input 1:   

5

Sample Output 1:

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

 

Sample Input 2:

3

Sample Output 2:

1 2 3

1 2

1

 

@MRProgrammer89 


CREATE CLASS < Main :

package Mr_Programmer;

import java.util.Scanner;

 

public class Main{

     public static void main(String[] args) {

     Scanner sc=new Scanner(System.in);

     System.out.println("Enter the value of n");

     int n = sc.nextInt();

     int m=1;

     for(int i=n;i>=1;i--)

             {

                    for(int j=1;j<=i;j++)

                    {

                           System.out.print(j+" ");

                    }

                    System.out.println();

             }

       }

}



@MRProgrammer89 


Write a program to print the Number pattern.

 

Input and Output Format:

Input consists of a single integer that corresponds to the number of rows,n.

The output is the alphabet pattern for the given input,n.

 

Sample Input 1:

5

Sample Output 1:

A

AB

ABC

ABCD

ABCDE

 

Sample Input 2:

7

Sample Output 2:

A

AB

ABC

ABCD

ABCDE

ABCDEF

ABCDEFG

 

 

@MRProgrammer89 


CREATE CLASS < Main :

package Mr_Programmer;

import java.util.Scanner;

public class Main{

       public static void main(String[] args) {

             int alphabet = 65,m=0;

        Scanner sc =new Scanner(System.in);

        int n = sc.nextInt();

             for (int i = 0; i <= n; i++)

        {

            for (int j = 0; j <i; j++)

            {

                System.out.print((char) (alphabet + j) + " ");

                m++;

            }

            System.out.println();

        }

 

       }

}


@MRProgrammer89 






MOTIVATION :


    “The way we spend our time defines who we are 


Although we may not see each other as often as we’d like, distance is no match for the bond that we share. Thank you for coming to visit. It was fantastic to catch up.


VISITE MORE BLOGS

Post a Comment

Thanks for reading the blog. We hope it was useful to you and that you learned something new. Will always be writing on new and interesting topics, so you can visit our website to know the latest updates of our blogs. Thank You!

Previous Post Next Post

Contact Form