Computer Science, asked by abigail123, 1 year ago

please do this i have exam after two hours ....java pattern

display this pattern
please answer
everytime i ask a question no one answer..... as if you don't know java patterns .....very annoying..​

Attachments:

Answers

Answered by siddhartharao77
5

Sample Program to print pattern in Java:

class Demo

{

public static void main(String args[])

{

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

{

int a = 65;

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

{

System.out.print(" ");

}

for(int k = 0; k <= 4 - i; k++)

{

System.out.print((char) (a + k) + "");

}

System.out.println();

}

}

}

Output:

ABCDE

  ABCD

     ABC

        AB

           A

Attachments:

siddhartharao77: :-)
SahilGill96: Which Ide are you using?
siddhartharao77: Online compilers!
Answered by Siddharta7
2

class Demo

{

public static void main(String args[])

{

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

{

int a = 65;

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

{

System.out.print(" ");

}

for(int k = 0; k <= 4 - i; k++)

{

System.out.print((char) (a + k) + "");

}

System.out.println();

}

}

}

Similar questions