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

What is called module?

561


Where is the singleton class used?

579


What is string :: npos?

576


What are three types of loops in java?

583


What does java final mean?

520






How do I print a “?

569


What is anti pattern in cyber security?

519


what happens when a thread cannot acquire a lock on an object? : Java thread

534


Explain the private protected method modifier?

540


What is method in java ?

620


In Java list the methods that can be overridden?

564


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

579


How many types of voids are there?

533


What is type inference in java8?

573


What advantage do java's layout managers provide over traditional windowing systems?

540