Tuesday, 1 March 2016

Types of pyramid programs pattern 17



Program
class Main{
public static void main(String args[]){
int i,j,k=1;
for(i=1;i<=4;i++){
for(j=1;j<=i;j++,k++)
System.out.print(" "+k);
System.out.println(" ");
}
}
}


OUTPUT:-
C:\Users\Saty\Desktop\java>javac 1.java
C:\Users\Saty\Desktop\java>java Main
 1
 2 3
 4 5 6
 7 8 9 10

No comments:

Post a Comment