Tuesday, 1 March 2016

Types of pyramid programs pattern 18



Program

class Main{
public static void main(String args[]){
int i,j;
for(i=5;i>=1;i--){
for(j=1;j<=i;j++)
System.out.print(" ");
for(j=1;j<=6-i;j++)
System.out.print("*");
System.out.print("\n");
}
for(i=1;i<=5;i++){
for(j=1;j<=i;j++)
System.out.print(" ");
for(j=1;j<=6-i;j++)
System.out.print("*");
System.out.print("\n");
}
}
}

OUTPUT:-
C:\Users\saty\Desktop>javac 1.java
C:\Users\saty\Desktop>java Main
     *
    **
   ***
  ****
 *****
 *****
  ****
   ***
    **
     *

No comments:

Post a Comment