Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Why singleton is not thread safe?

999


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

1001


Is null a string?

1016


What is the difference between private & public & friendly classes?

1080


What is the benefit of singleton pattern?

996


How do you empty a list in java?

988


List the interfaces which extends collection interface?

961


Can memory leak happen java?

1014


Can a constructor be made final?

1121


What does the @override annotation do?

1050


What is the output of the below java program?

1060


What are the 4 types of characters?

1022


Can we store variables in local blocks?

1360


What is the default value of byte datatype in java?

943


Can a class extend more than one class?

1131