Java program to display triangle 1 23 456 78910

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* 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");
       }
	}
}

5 Responses to “Java program to display triangle 1 23 456 78910”

  1. this is bad site please stop it. because nobody can not see the actual code because your advertisement is disturb a lot . which is display on code.please remove it.

    Reply
  2. Surendrakumar

    can you write a String array .. like Triangle Shape . String array contain. 12345678910.

    Reply
  3. siddeshwer

    give me code for following patterns
    1.
    1 3 8 15
    24 35 48
    63 80
    99
    2.
    1 8 27
    64 125 216
    343 512 729

    3.
    0 2 4
    6 10 12
    18 22 28
    30 36 40

    Please give it quick…

    Reply

Leave a Reply