Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java triangle

import java.util.Scanner;

public class triangle {
    public static void main(String[] args) {
        Scanner userInput = new Scanner(System.in);
        int n = userInput.nextInt();
        for (int row = 0; row < n ; row++) {
            for (int i = 0; i < row ; i++) {
                System.out.print(".");
            }
            for (int i = 0; i < n-row ; i++) {
                System.out.print("*");
            }
            System.out.println();
        }

    }
}
 
PREVIOUS NEXT
Tagged: #java #triangle
ADD COMMENT
Topic
Name
2+5 =