Output
----------
*
* *
* * *
* * * *
* * * * *
Pyramid Program 1
Source code
-------------
package com.swain.cell;
public class Piramid {
public static void main(String args[]){
int p=1;
for(int i=1;i<=5;i++){
for(int j=i;j<5;j++){
System.out.print(" ");
}
for(int k=1;k<=p;k++){
if(k%2==0){
System.out.print(" ");
}else
System.out.print("*");
}
System.out.println();
p+=2;
}
}
}
No comments:
Post a Comment