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


Please Help Members By Posting Answers For Below Questions

What is nan in java?

510


Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.

522


What are the differences between getting and load method?

534


who can i handle multiple client in RMI

1433


How does a cookie work in Servlets?

336






What is queue in java?

552


How do you convert bytes to character in java?

528


Can a class have multiple subclasses?

578


Can we write method inside a method in java?

517


Can we write class inside a class in java?

543


How many characters is 16 bytes?

531


Can we have multiple catch block for a try block?

582


Explain the concept of hashtables?

607


explain multi-threading in java?

544


What is boolean data type in java?

559