Java program to display triangle 1 23 456 78910

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
/* Display Triangle as follow : BREAK DEMO.
   1
   2 3
   4 5 6
   7 8 9 10 ... N */
class Output1{
	public static void main(String args[]){
		int c=0;
		int n = Integer.parseInt(args[0]);
loop1: for(int i=1;i<=n;i++){
loop2: for(int j=1;j<=i;j++){
	       if(c!=n){
		       c++;
		       System.out.print(c+" ");
	       }
	       else
		       break loop1;
       }
       System.out.print("\n");
       }
	}
}

Comments

Popular posts from this blog

VirusTotal Lets Apple Fans Play With Fire In The Malware Sandpit

iPhone 5se Design Tipped in New Leak, to Look Like iPhone 5s

Freedom 251 - World's Cheapest Smartphone