Tuesday, 1 March 2016

Types of pyramid programs pattern 20


Program

class Main{
public static void main(String args[]){
int n=5,row=5,col=5;
int c=4;
for(int i=0;i<row;i++)
{
for(int j=0;j<col;j++)
{
if(i==0||i==4)
System.out.print("*");
else if(j==c)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
c--;
}
}
}

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

No comments:

Post a Comment