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
Difference between method overloading and method overriding in java ?
Write a program to print the pattern given below
What is void keyword?
What is mysql driver class name?
What will happen if static modifier is removed from the signature of the main method?
Can we inherit a class with private constructor?
How infinite loop is declared?
What is runtime locatable code?
How many types of memory areas are allocated by JVM in java?
What happens when a thrown exception is not handled?
Define reflection.
Explain the private protected method modifier?
What is the use of math abs in java?
How can you read an integer value from the keyword when the application is runtime in java? example?
Describe how to implement singleton design pattern in struts.