Computer Science, asked by OVERLOADofSTUDIES, 3 months ago

hey please help me with this pattern. it's a pyramid of alphabets and I'm not able to print it. thankyou *irrelevant and rubbish answers will be reported*​

Attachments:

Answers

Answered by BrainlyProgrammer
4

Answer:

This can be done in two ways

Approach 1:-

public class CharLoop{

   public static void main(String ar[]){

       for(char i='A';i<='F';i++){

           for(char j='F';j>i;j--){

               System.out.print(" ");

           }

           for(char j='A';j<=i;j++){

               System.out.print(j);

           }

           for(char j=(char)(i-1);j>='A';j--){

               System.out.print(j);

           }

           System.out.println();

       }

   }

}

_

Approach 2:-

public class CharLoop{

   public static void main(String ar[]){

       for(int i=65;i<=70;i++){

           for(int j=70;j>i;j--){

               System.out.print(" ");

           }

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

               System.out.print((char)(j));

           }

           for(int j=(i-1);j>=65;j--){

               System.out.print((char)(j));

           }

           System.out.println();

       }

   }

}

_

•Output Attached

_

♬•••♪

Attachments:
Similar questions