Sunday 7 July 2013

Java progaram to generate pyramid

public class JavaPyramid4 {

        public static void main(String[] args) {
             
                for(int i=1; i<= 5 ;i++){
                     
                        for(int j=0; j < i; j++){
                                System.out.print(j+1);
                        }
                     
                        System.out.println("");
                }

        }
}

 Output of the above program would be
*
**
***
****
*****

No comments:

Post a Comment