Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

control structures and array

  Asked By: ENCIK    Date: Mar 03    Category: Java    Views: 1267
  

write a program to print the following triangle of numbers
like this:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

how to to write this program?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Murali Krsihna     Answered On: Mar 22

for(int i=1;i<6;i++){
for(int j=1;i>=j;j++){
System.out.print(j);

}
System.out.println();
}

 
Didn't find what you were looking for? Find more on control structures and array Or get search suggestion and latest updates.




Tagged: