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");
       }
	}
}
surajk

3 thoughts on “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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in