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



Home Answers Viewqa Java-Beginners loops , control structures
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nisha
loops , control structures
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


a simple java program to print

                       1
                     1 2 1
                   1 2 3 2 1
                 1 2 3 4 3 2 1

Advertisement
View Answers

March 31, 2011 at 3:15 PM


class Pyramid{
     public static void main(String[] args){
     int x = 4;  
     for(int i = 1; i <= x; i++) {  
     for(int j = 1; j <= x - i; j++)  
     System.out.print("   ");  
     for (int k = 1; k <=i; k++)  
     System.out.print((k>= 10) ?+ k : "  " + k); 
     for (int k = i-1; k >= 1; k--)  
     System.out.print((k >=10) ?+ k : "  " + k);  
     System.out.println();  
    }  
  }
}


Related Tutorials/Questions & Answers:
loops , control structures
loops , control structures  a simple java program to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1
loop, control structures
loop, control structures  a java program to print
Advertisements
PHP Control Structure
Control Structures: Generally a PHP script is made of a series of statements which includes assignment, collection of functions, loop, conditional statements etc. In PHP except the last line we need to put a semicolon after every line
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 a message at every second, and terminates when the time expires. Use method
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
Loops
Loops  by using drjava q1.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 q2.Write code
Structures and unions
Structures and unions  union{ struct{ int i1; char c1; }s1; struct{ int i2; char c2; }s2; }u1; what will be the value of (int)u1.s1.i1-(int)u1.s2.i2 and (int)&u1.s1-(char)u1.s1.c2
looping structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
data structures - Java Beginners
data structures  I have got a project of the subject 'data structures and C++' and the topic is 'types of graphs'. please guide me on this topic and help me finding material of this topic
File structures and indexes
File structures and indexes  for the following BCNF relations that describe departments in a company and employees Dept(did,dname,location,managerid) Emp(eid,sal) Now for this system the following queries are important: List
Loops
3.10. Loops Loops are the essential part of the program that have.... More than one loops can be used several times in a script. Loops makes easy... instructed for repetition of the code. PHP Loops In PHP, like other programming
nested for loops
"); } } } }   Close your loops before going
use of loops and screenshots
use of loops and screenshots  1.how to use loops in netbeans? 2.how to draw a correct screenshot
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
Data structures and algorithmms - Java Server Faces Questions
Data structures and algorithmms  Could u provide me with a solution to assignment COS212Assignment2008.doc on http://www.cs.up.ac.za
How to read loops in Java
How to read loops in Java  Example that explains how to read loop in Java
Use javascript loops..
Use javascript loops..  Write a Javascript code to create a redirection script based on day of the week
LOOPS - Java Interview Questions
LOOPS   how to find out unique number of elements in given array?{1,2,5,3,2,1,1,7,2,3,0,1,5} output is: 1-4 2-3 3-2 5-2 0-1 7-1 i want source code plz help me
Using Nested loops
Using Nested loops  How to use nested loops in java when I want to print the 10 multiples of numbers 2 to 15(in multiplication table)   public class MultiplicationTable{ public static void main(String[] args) { int
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops) * ** * ** * ** *   the correct pattren
while loop to for loops
while loop to for loops  I have to change this while loops to for loops and I was wondering if you could help me out. I got the codes just need to know how to change it. int currentNum= num1; while(num1>num2
Use javascript loops..
Use javascript loops..  Write a JavaScript code to find a number of unique letters in string. (Eg. if keyword is Tajmahal, Tajmahal count will be '5' , it only takes these letters T,j,m,h,l , not taken the letter a because
LOOPS !! - Java Interview Questions
LOOPS !!  i have string "Hello" i want to print like H He Hel Hell Hello o ol oll olle olleh i want source code plz help me?  String s="Hello"; System.out.println(s.length()); System.out.println
 

 

 

DMCA.com