+ 3

This programm not giving output in triangle manner?

public class AngledTriangle { public static void main(String[] args) { int height = 8; for(int i = 1; i <= height; i++) { for (int j = 1; j <= i; j++) { System.out.println("*"); } System.out.println(); } } }

20th Jul 2019, 11:37 AM
Ânkít Surwade
Ânkít Surwade - avatar
8 Answers
20th Jul 2019, 11:51 AM
Aparesh Bhunia
Aparesh Bhunia - avatar
+ 2
What is your aim with the program? It gives the following error message: ..\Playground\:1: error: class, interface, or enum expected
20th Jul 2019, 11:43 AM
Lennie
Lennie - avatar
+ 2
Sorry Lennie.....it's working properly on my screen. just not showing triangle .
20th Jul 2019, 11:48 AM
Ânkít Surwade
Ânkít Surwade - avatar
+ 2
public class AngledTriangle { public static void main(String[] args) { int height = 8; System.out.println ("*"); for(int i = 1; i < height; i++) { System.out.print ("*"); for(int j = 1; j <= i; j++) { System.out.print(" "); } System.out.println("*"); } for (int j = 1; j <= height; j++) { System.out.print(" *"); } } } //here sololearn help me//
20th Jul 2019, 11:52 AM
Ânkít Surwade
Ânkít Surwade - avatar
+ 2
just use ‘print’ instead ‘println’ in your first print statement
20th Jul 2019, 8:32 PM
Sai Ram
+ 1
Thank You Zhenis Otarbay
20th Jul 2019, 12:02 PM
Ânkít Surwade
Ânkít Surwade - avatar
+ 1
That's great Aparesh Bhunia
20th Jul 2019, 12:10 PM
Ânkít Surwade
Ânkít Surwade - avatar