Friday, August 10, 2012

Pyramid Program 3


Pyramid Program 3
 Output
----------
 1
 1 2
 1 2 3
 1 2 3 4
 1 2 3 4 5
 1 2 3 4
 1 2 3
 1 2
 1
Pyramid Program 3
Source code
-------------
package com.swain.cell;

public class Piramid3 {

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

No comments:

Post a Comment

How ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...