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



Home Answers Viewqa Java-Interview-Questions I need to output number diamond using nested for loops.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jiawei Tan
I need to output number diamond using nested for loops.
1 Answer(s)      3 years and 7 months ago
Posted in : Java Interview Questions


How to i output this using nested for loops

    1
   131
  13531
 1357531
135797531
 1357531
  13531
   131
    1

Advertisement
View Answers

May 24, 2011 at 4:20 PM


class Pyramid{
public static void main(String[] args){
    for(int row = 1; row <= 5; row++){
for(int col = 4; col >= row; col--){
System.out.print(" ");
}
for(int col2 = 1; col2 <= row*2; col2+=2){
System.out.print(col2);
}
for(int col3 = row*2-3; col3 >= 1; col3-=2){
System.out.print(col3);
}
System.out.println();
   }
   }
  }


Related Tutorials/Questions & Answers:
I need to output number diamond using nested for loops.
I need to output number diamond using nested for loops.  How to i output this using nested for loops 1 131 13531 1357531 135797531 1357531 13531 131 1
Using Nested loops
Using Nested loops  How to use nested loops in java when I want...[][] array = new int[16][16]; for (int i=1; i<array.length; i++) { for (int j=1; j<array[i].length; j++) { array[i][j] = i*j; System.out.print(" " + array[i][j
Advertisements
nested for loops
nested for loops  Hello all, I have created a program(gui... the totals after each entry, when all I need is just a total of all entries. This is my first time using java and my first time programming, but I am guessing
nested loops
nested loops  please tell input to get the output: 12345 23456 34567 45678
Nested Ajax--not getting output
Nested Ajax--not getting output  Hi everyone... I have two.jsp page from that , with the help of ajax i have called three.jsp. So, i have used DIV... time running...when i run One.jsp , with the help of ajax when i call two.jsp.
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops... A { public static void main(String[] args) { for(int i=0;i<5;i
Loops
Loops  by using drjava q1.Write code that uses nested loops to print... that ask user to insert an integer (n) and prints out the factorial (n!) of this number. n! = n (n-1)(n-2)(n-3)â?¦â?¦â?¦1 , n > 0 plzz i need
read string - using loops in Java
read string - using loops in Java  Write a program to read a string composed of an unknown number of words, then count the number of words in the string, and Display the longest and shortest words, with first letter Uppercase
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
Loops
Loops  ??Using for loops, Write a program to simulate a clock countdown. The program prompts the user to enter the number of seconds, displays... System.currentTimeMillis() which return the number of milliseconds since the epoch
Solve using only Javascript loops...
Solve using only Javascript loops...  Write a JavaScript code, 1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique...; sortedArray.length; i++){ count++; } document.write("Number
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
loops
loops  I need the program output 55555 4444 333 22 1 like this by using for loop and if condition only
Nested If Statement
. Here we are providing you an example using Nested-If statement. In the example, we... Nested If Statement       In this section you will study about the Nested-if Statement in jsp
I/O Program output error
I/O Program output error  Hello All, I am working on a program... file, but I am getting incorrect output. I have been successfull with part of the program in that it reads the text file and analyzes it, however I need it to take
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
Write a program that (algorithmically) shows a times table.(convert integers to strings, format text, nested loops)
Write a program that (algorithmically) shows a times table.(convert integers to strings, format text, nested loops)   Write a java program..., nested loops) 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Java repeat string without using loops
Java repeat string without using loops In this section, you will learn how to repeat string without using for loops. The given example accepts the number of times and iterates the string to the number of times set by the user without
Diamond shape num - Java Interview Questions
Diamond shape num  How To Print Diamond Shape Numbers I Want Logic?Using For loops?  Hi Friend, Try the following code: public class Diamond{ public static void main(String[] args){ int row = 5; for(int i=1
i need a school appication using struts frame work with oracle 10g using myeclipse6.0
i need a school appication using struts frame work with oracle 10g using myeclipse6.0   hi i need a school apllication using struts frame work backend 10g xe using myeclipse 6.0
print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using...{ public static void main(String[] args){ for(int i=1;i<=100;i++){ System.out.println(i); } } } Thanks   Hi Friend
print rectangle triangle with ?*? using loops
print rectangle triangle with ?*? using loops   * * * * * * i want print like this.what is the code?   import java.lang.*; class Traingles { public static void main(String args[]) { for(int i=1;i<=5
Java reverse words in a string using only loops
Java reverse words in a string using only loops In this tutorial, you will learn how to reverse words in a string without using any inbuilt methods like split() etc, StringTokenizer functiom or any extra ordinary function Only loops
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer...) Write an application that computes the value of ex by using the formula ex = 1...=new Scanner(System.in); System.out.print("Enter Number: "); int m
output using SQL
output using SQL  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d
 

 

 

DMCA.com