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
Why is method overloading not possible by changing the return type in java?
How static variable work in java?
How can an object be unreferenced?
How to provide security in java
How will you add panel to a frame?
what are different ways in which a thread can enter the waiting state? : Java thread
Can you declare an interface method static?
What is difference between overloading and overriding in java?
What is polymorphism in java? What are the kinds of polymorphism?
What are the differences between heap and stack memory?
What is the return type of the main method?
What is variable in java?
What is java oops?
What is considered an anti pattern?
What is the abstract class?