+ 1

How to create looping java code?

How to create code java looping for this output? Output: Input n: 4 * ** *** ****

8th Jan 2019, 6:40 PM
ZULFITRI (Ijoell)
ZULFITRI (Ijoell) - avatar
5 ответов
+ 10
ZULFITRI Please, go to Code playground, write one of these solutions and practice!👍 int n = 4; /* * Outer loop to handle number of rows * 'n' in this case. */ for (int i = 0; i < n; i++) { /* * Inner loop to handle number of * columns. * Values changing acc. to outer loop. */ for (int j = 0; j <= i; j++) { // Printing stars. System.out.print("*"); } // Ending line after each row. System.out.println(); }
8th Jan 2019, 7:35 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 6
public class Program { public static void main(String[] args) { int number_of_rows = 10; for(int i = 0; i < number_of_rows; i = i + 1){ for(int n = 0; n < i + 1; n ++){ System.out.print("*"); } System.out.print("\n"); } } }
8th Jan 2019, 7:20 PM
Maneren
Maneren - avatar
+ 3
For loop in range from 1 to <=4 as i Inside another for loop in range from 1 to 1<=i Inside second for loop: System.out.print("*"); after second for loop: System.out.println();
8th Jan 2019, 6:56 PM
Michal
Michal - avatar
+ 2
try to check this out, it should help. https://code.sololearn.com/c2UK8ZElW8Er/#java
8th Jan 2019, 7:30 PM
Yussuf Toheeb
Yussuf Toheeb - avatar
+ 1
Thanks for answers
9th Jan 2019, 3:27 AM
ZULFITRI (Ijoell)
ZULFITRI (Ijoell) - avatar