Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Printing numbers in pyramid format
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


MOULANA SHAIK
Printing numbers in pyramid format
1 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners


Q) Can you please tel me the code to print the numbers in the following format:
1
2 3
4 5 6
7 8 9 10

Advertisement
View Answers

June 30, 2010 at 2:54 PM


Hi Friend,

Try the following code:

public class Pyramid{
public static void main (String[] args) throws Exception{
int k = 1;
for(int i=1; i<= 4 ;i++){
for(int j=1; j <= i ; j++){
System.out.print(k+" ");
k = k + 1;
}
System.out.println("");
}
}
}

Thanks


Related Tutorials/Questions & Answers:
Printing numbers in pyramid format - Java Beginners
Printing numbers in pyramid format  Q) Can you please tel me the code to print the numbers in the following format: 1... the following code: public class Pyramid{ public static void main (String
Application for print pyramid of numbers
Application for print pyramid of numbers  What is the code for printing the numbers like 1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
Advertisements
Numbers pyramid
Numbers pyramid  Hi sir, Can you please tell me how to output this using nested for loops? 1 2, 1 1, 2, 3 4, 3, 2, 1 1, 2, 3, 4, 5 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7 8, 7, 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7, 8, 9 10, 9, 8
nmber printed in pyramid format
nmber printed in pyramid format  how to print this format using java 1 23 345 4567 56789
Java Pyramid of Numbers
Java Pyramid of Numbers  Hi, I want to know how the code to print the pyramid below works. It uses nested for loops. Pyramid: 1 2 1 2
Printing numbers up to N into a file
Printing numbers up to N into a file  I'd like to print the first N integers, that is, "1, 2, 3, 4, ..., N-1, N", say N equals 1000, or 10000 or whatever. I'd also like to have the result stored as a file instead of having
pyramid
pyramid  hi frnds i need java code for pyramid. the pyramid look like this A BAB CBABC BAB
pyramid
pyramid  hi i need java code for pyramid. the pyramid look like this. A BAB CBABC BAB
pyramid
pyramid  how to print 1 22 333 4444 55555   class Pyramid { public static void main(String[] args) { for(int i=1;i<=5;i++){ for(int j=1;j<=i;j++){ System.out.print(i
pyramid
pyramid  How to get the code for the following pattern * * * * * * * * * *   class Pyramid{ public static void main(String args[]){ for(int i=1;i<=4;i
pyramid
pyramid  How to get the code for the following pattern * * * * * * * * * *   class Pyramid{ public static void main(String args[]){ for(int i=1;i<=4;i
pyramid
pyramid  how to get the output like this A BB CCC DDDD   Hi Friend, Try the following code: class Pyramid { public static void main(String[] args) { for(char ch1='A';ch1<='D';ch1
number pyramid
;class Pyramid{ public static void main(String args[]){ for(int i=1;i<=7...; class Pyramid{ public static void main(String args[]){ for(int i
Number Pyramid
for the following number pyramid: print.... So far I have this: print("import java.util.Scanner; class Pyramid { public... Pyramid { public static void main(String[] args) { Scanner input = new Scanner
printing java series
printing java series  * *** ***** ******** ***** *** *   Post the format properly
printing in swing
printing in swing  How can i print payslip in swing
applet printing
applets gridwise and in each applet i am drawing some graph so while printing whole... but while printing it is not getting printed on paper and rest everything it is printing
PYRAMID - Java Beginners
will display triangle or pyramid... The user must choose A, B, or C...: A (so it will display a Pyramid OR TRIANGLE) would you like to continue y... OR PYRAMID NOTE: SORY I TRY TO DRAW A PYRAMID OR TRIANGLE BUT IT WILL NOT DISPLAY
printing in java
printing in java  hello i want to print a jInternalframe containing some lebels,but my printer sent me a paper with the following written on it: please what is the problem
Printing stars
Printing stars  I am a beginer and i have one assignment which couldnt give me any idea how to do it..The Question is "Get a string "001222014654" and print o/p as 0 - * 1- ** 2- * 4- ** 5-* 6-* I dont know how to split
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: ibrahimbest@gmail.com
Number Format Example
Number Format Example       This Example shows you how to format numbers according to the locale... numbers. NumberFormat class also provides methods for defining which locales have
Printing server information
Printing server information  Hello, I am learning PHP language. I trying to fetch the server Information Print. How could i will printing the server... connected to your PC? This it best example for the Printing server Information
printing records from jsp - JSP-Servlet
printing records from jsp  Hi Plz tell me how to printing out pages from jsps with page numbers Thank you  Hi friend, For paging in Jsp visit to : http://www.roseindia.net/jsp/paging.shtml http
print numbers in traingle shape
print numbers in traingle shape  1 22 333 4444 i want output like this please help me   class Pyramid { public static void main(String[] args) { for(int i=1;i<=4;i++){ for(int j=1;j<
printing example - Java Beginners
printing example  Is it possible to print java controls using print method? My problem is to print a student mark list using java? The mark list should like that of university mark list
 

 

 

DMCA.com