WAP TO PRINT THE PYRAMID.
public class Pyramid
{
public static void main(String [] args) {
int i,j;
char ch= 'A';
for(i=1;i<=3;++i) {
for(j=1;j<=9;++j) {
if((i+j)%2==0&&j>=i&&(i+j)>=6&&(j-i)<=4&&(j-i)>=0)
System.out.print(ch);
else
System.out.print(" ");
}
System.out.println();
ch++;
}
for(i=4;i<=5;++i) {
for(j=1;j<=9;++j) {
if((i+j)%2==0)
System.out.print(ch);
else
System.out.print(" ");
}
System.out.println();
ch++;
}
}
}
NOTE:
The above program has been designed on basis of the co-ordinate system. Where both the co-ordinates of both the axes start from 1.
by,
ANUBRATA DAS