Program to output as below formate:
1
2 3
4 5 6
7 8 9 10
Answer Posted / dhananjaya nawarathne
public class formatNumbers {
public static void main(String args[])
{
int k=1;
for(int i=1;i<5;i++)
{
for(int j=0;j<i;j++)
{
System.out.print(k++ + " ");
}
System.out.print("
");
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What does the “static” keyword mean?
Is alive and join method in java?
Can a class have more than one object?
What is an iterator java?
Which programming language is best in future?
What is a qualifier in a sentence?
Can we overload the main() method?
What is finalize()? Is finalize() similar to a destructor?
What is the difference between final, finally and finalize()?
Which is fastest collection in java?
Can a class be defined inside an interface?
What are internal and external variables?
What is final method?
Is an array a vector?
How do you insert a line break?