Home Answers Viewqa Java-Beginners loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1

 
 


Sara Roz
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1
1 Answer(s)      a year ago
Posted in : Java Beginners

Hi, I want to know how the code to print the pyramid below works. It uses nested for loops.

Pyramid: 1 1234 12 123 123 12 1234 1

View Answers

May 14, 2012 at 1:10 PM


Here is the code that will display some pattern of numbers in the form pyramid.

class Pattern 
{
    public static void main(String[] args){

        for(int i=1;i<=4;i++){
            for(int j=1;j<=i;j++){
                System.out.print(j);
        }
         System.out.println();
        }
         System.out.println();
        for(int i=4;i>=1;i--){
        for(int j=1;j<i+1;j++){
            System.out.print(j);
        }
          System.out.println();
        }
    }
}









Related Pages:
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1  Hi, I want to know how the code to print the pyramid below works. It uses nested for loops. Pyramid: 1 1234 12 123 123 12 1234 1
print numbers
print numbers  1234 123 12 1234   1234 123 12 1234
for loop
for loop  how to performs the for loop when 2 inputs given like displays the triangle shape and how to take initial values or declaration values plz explain in detailed ex. 1 12 123 1234
Java Programming, Chapter 12 Exercises
. static final int SIN = 0, COS = 1, // Code numbers for each... Programming Exercises For Chapter 12 THIS PAGE CONTAINS programming exercises based on material from Chapter 12 of this on-line Java
Java Programming, Chapter 12 Quiz Answers
; // Month number in range 1 to 12. int day; // Day number in range 1...; // Month number in range 1 to 12. int day; // Day number in range... Sample Quiz Answers For Chapter 12 THIS PAGE CONTAINS SAMPLE
Java Programming, Chapter 12 Quiz
. class Date { int month; // Month number in range 1 to 12... Quiz Questions For Chapter 12 THIS PAGE CONTAINS A SAMPLE quiz on material from Chapter 12 of this on-line Java textbook. You should
Java Programming: Chapter 12 Index
of Chapter 12: Section 1: Generic Programming Section 2: List and Set Classes... Chapter 12 Generic Programming and Collection Classes HOW TO AVOID... have to re-code these data structures from scratch. They are well-understood
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java Question
in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4 123456 12345 1234 123 12 1
java
java  hello, i need a java program to print the nos in this manner a) 1 12 123 1234
java program 12
java program 12  Write a java program to verify whether the given number is palindrome or not by taking from input Buffer reader(console).  ...=""; for(int i=str.length-1;i>=0;i--){ reversedSt+=str[i
javaprograms
javaprograms  compute the following series s=1+12+123+1234+............+123....n terms
java programming:generating series
series: 12345 1234 123 12 1 1 12 123 1234 12345 12345   Here is a code that displays the following pattern: 12345 1234 123 12 1 1 12 123 1234...) { for(int i=5;i>=1;i--){ for(int j=1;j<i+1;j
java programming:generating series
java programming:generating series  12345 1234 123 12 1 1 12 123 1234 12345   Here is a code that displays the following pattern: 12345 1234 123 12 1 1 12 123 1234 12345 class Pattern { public
Finding a Factorial using while loop
Finding a Factorial using while loop      In this example we are going to find out the factorial of 12 by using the while loop. In while loop the loop will run until the condition we have given
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
Counting
on pop up menu. 1 12 123 1234 12345 123456 1234567 12345678 123456789   Java Print Pattern 1 12 123 1234 12345 123456 1234567 12345678 123456789... i=1;i<=9;i++){ for(int j=1;j<i+1;j
Finding a Factorial using while loop
are going to find out the factorial of 12 by using the while loop. In while loop...;% int value = 12, factorial = 1, temp = value; while (temp > 0...Finding a Factorial using while loop   
loop
to output the following code using a loop the code is as follows with the user inputs in inverted commas,thanks. ENTER CODE(XX to Stop) CODE:"D24" QUANTITY:"2" CODE:"K19" QUANTITY:"1" CODE:"XX"   import java.util.*; class Output
Code for Pattern
Code for Pattern  1 1 12 12 123 123 1234512345 Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Java Interview Questions - Page 12
Java Interview Questions - Page 12   ... to transfer data. Question: Does the code in finally block... will not be executed when the System.exit(1) statement is executed earlier
Chapter 12. Exceptions
Chapter 12. ExceptionsPrev Part I. Exam Objectives Next    Chapter 12. ExceptionsIdentify correct and incorrect statements or examples about exception handling
print this image in java code using only loop{for, if, loop}
print this image in java code using only loop{for, if, loop}  ... is a code that displays the following pattern...;j<9;j++) { s[i][j]='*'; } } for(i=0;i<4;i++) { for(j=1;j<4
java code and logic - Java Beginners
java code and logic  how to write the program in java for 123454321 1234 4321 123 321 12 21 1 1 thanks  Hi Friend, Try the following code: class Program { public static void main(String
java
java   give me program for this output 12345 1234 123 12 1   public class PatternExample{ public static void main(String[] args){ for(int i=5;i>=1;i--){ for(int j=1;j<i+1;j
java programming:generating series
java programming:generating series  1234554321 1234 4321 123 321 12 21 1 1   Here is a java code that displays the following pattern 1234554321 1234 4321 123 321 12 21 1 1 class Pattern
for loop
for loop  what is for loop   Loops are used for iteration which means to execute a part of code repeatedly. Repetition of a part of code can be done for a number of times or infinitely. If repetition of code is done
logic for pattern program
* 1234 4321 *** 123 321 ***** 12 21 *** 1 1 * 123321 1 1 12 21 1212 2323 1 1 123123 345456 12 21... that whoe's program code its make this type output
Description
1234 4321 123 321 12 21 1 1 PLZ DESCRIBE ME THAT HOW TO MAKE THIS PROGRAM AND WHATS THE WORKING OF EVERY LOOP   The above code...=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print
Description
1234 4321 123 321 12 21 1 1 PLZ DESCRIBE ME THAT HOW TO MAKE THIS PROGRAM AND WHATS THE WORKING OF EVERY LOOP   The above code...=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print
Description
1234 4321 123 321 12 21 1 1 PLZ DESCRIBE ME THAT HOW TO MAKE THIS PROGRAM AND WHATS THE WORKING OF EVERY LOOP   The above code...=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print
Description
1234 4321 123 321 12 21 1 1 PLZ DESCRIBE ME THAT HOW TO MAKE THIS PROGRAM AND WHATS THE WORKING OF EVERY LOOP   The above code...=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print
javaprograms
javaprograms  write program s=1+12+123+1234+.........+123....n terms...(); int sum=0; int m=0; for(int i=1; i<=n; i++){ for(int j=1; j<=i; j++){ System.out.print(j); sum+=j
loop error - Ajax
, as i mention.. after giving my code the out put shows.... 1 2...loop error  Expert:ARIJEET sory....dude....it's not my perfect solution... i give the code...just like...    
diamond print
diamond print   print the pattern 1 2 3 4 5 6 7 8 9 10 11 12
How can print integer in method
process(int jobid,int remain){ } how to print int jobid ,int remain in for loop jobid in proc[0],remain in proc[1],both show in text file how to print proc[0] & proc[1] in System.out.println() proc[0]:12 1 4 3 proc[1]:13 7 3 1 thankyou
print array in following format
want output as: 1 2 3 11 12 13 4 5 6 14 15 16 7 8 9 17 18 19   Here is a code that displays the array values in the following pattern: 1 2...print array in following format  i want print two array in following
'for' Loop
is the same loop using for. for (int number = 1; number <= 12; number... using while: int number = 1; while (number <= 12... Java Notes'for' Loop Purpose The for statement is similar
for loop
for loop  using only two for loop how can print below numbers 1... 5 4 4 4 4 3 3 3 2 2 1   Here is a number pattern: 1 2 2 3 3... 2 2 1 class Pattern{ public static void main(String[] args
for loop
for loop  using only two for loop how can print below numbers 1... 5 4 4 4 4 3 3 3 2 2 1   Here is a number pattern: 1 2 2 3 3... 2 2 1 class Pattern{ public static void main(String[] args
program - Java Beginners
program  a program to print 123454321 1234 4321 123 321 12 21 1 1  make sure about ur first line 123454321 or 1234554321   Hi punnet if query is correct then the code like
Java I/O Assistance + Loop
my loop I believe I just cant wrap my head around how to get a proper display..., 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420..., 2450, 2550, Clearly NOT 2,4,6,8,10,12,14,.,.,.Etc print("package textFileIO
prepared statement in for loop - JDBC
if"); pst1.setString(1, "123"); pst1.setString(2... in a for loop. But my problem is that only one row is getting inserted... doing anything wrong? Here is my code: strB2B = (String)poForm.get("POB2B
JavaScript array for loop
for loop is executed in a JavaScript. The code import the following packages- 1... with initial size to hold 12 element. The for loop execute and run the script... JavaScript array for loop     
loop problem - Java Beginners
loop problem  I trying to write a program which prints out even...: 2 4 6 8 10 12 14 16 18 20 I tried using a counter, but I'm missing something. Can you help?   Hi Friend, Try the following code: class

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.