Program to output as below formate:
1
2 3
4 5 6
7 8 9 10

Answer Posted / jyoti

public class format {
public static void main(String args[])
{
int k=1;
for(int i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
System.out.print(k++ + " ");
}
System.out.print("\n");
}
}
}

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell some latest versions in JAVA related areas?

564


What is the difference between a scrollbar and a scrollpane?

572


Can we use return in constructor?

497


How many threads does a core java have?

515


How to change the priority of thread or how to set the priority of thread?

619






Give me example of derived data types.

598


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

640


Is java still necessary?

628


What is the difference between and ?

518


How to optimize the javac output?

604


What is an exception? difference between Checked and Unchecked exception in Java

565


Explain access modifiers in java.

590


What is the string function?

561


What is linked hashset and its features?

554


What is a singleton class in Java?

516