Computer Science, asked by kaashviGoel, 4 days ago

Write the Java program to solve the display the following series​

Attachments:

Answers

Answered by harrykalsiboy
0

Answer:

(a)

public class Pattern

{

public static void main main(String args [])

{

int a,b;

a=0;

b=5;

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

{

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

{

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

a++;

}

System.out.println();

}

for(int i=2; i>=0;i--)

{

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

{

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

b--;

}

System.out.println();

}

}

}

Explanation:

in above program two sets of for loops are used one to print first half of the pattern from 0 to 9.

and second set of loop is used to print the lower half from 5 to 0

(b) pattern can be drawn by making few changes in the above program.

Try Yourself.

Similar questions