Program to print 1
1 2
1 2 3
1 2 3 4 like that
Answer Posted / yun hin
class triangle{
public static void main(String args[]){
int height = 5;
for(int i=1;i<=height;i++){
for(int j=1;j<=(height-i);j++){
System.out.print(" ");
}
for(int k=1;k<i;k++){
System.out.print(k + " ");
}
System.out.print(i);
System.out.println();
}
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
Is static variable stored in heap?
What is difference between c++ and java ?
How can I become a good programmer?
What are the 3 types of loops in java?
Can constructor be static or final?
Explain about fail safe iterators in java?
What is a function argument in java?
extending thread class or implementing runnable interface. Which is better? : Java thread
What is a modifier?
How many types of design patterns are there?
What do you mean by JVM?
Is java hashset ordered?
What is wrapper class html?
What are the Class Libraries ?
What are different types of inner classes ?