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
How many bits is a boolean?
What is the use of volatile in java?
In Java list the methods that can be overridden?
What happens if an exception is throws from an object's constructor?
What is the difference between C++ and Java and your preferences?
What is valid keyword in java?
How to sort elements in a parallel array in java?
What is meant by oops concept in java?
what is deadlock? : Java thread
What is the benefit of inner / nested classes ?
What is the replace tool?
Is null function in java?
What is args length in java?
Do I need to import java.lang package any time? Why?
What is a "pure virtual" member function?