Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Pyramid pattern program in java

// pyramid pattern - TutorialsTonight

public class pyramid {
  // pyramid star pattern
  public static void main(String[] args) {

    int size = 5;
    for (int i = 0; i < size; i++) {
      // print spaces
      for (int j = 0; j < size - i - 1; j++) {
        System.out.print(" ");
      }
      // print stars
      for (int k = 0; k < 2 * i + 1; k++) {
        System.out.print("*");
      }
      System.out.println();
    }
  }
}
/* Output:
    *
   ***
  *****
 *******
*********

*/
Source by www.tutorialstonight.com #
 
PREVIOUS NEXT
Tagged: #Pyramid #pattern #program #java
ADD COMMENT
Topic
Name
2+6 =