You are on page 1of 1

Write a section of code in Java that will print the following designs: a) * ** *** **** ***** (a) Answer:

int row, col ; for (row = 1 ; row <= 5; row++) { for (col=0 ; col <row ; col++) System.out.print("*"); System.out.println(); } } (b) Answer: int row, col ; for (row = 1; row <=5; row++) { for (col=6 -row; col>0; col--) System.out.print("*"); System.out.println(); } } b) ***** **** *** ** *

You might also like