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



Home Answers Viewqa Java-Beginners loop, control structures

Have Programming Question? Ask it here!
 
 
 


nisha
loop, control structures
1 Answer(s)      3 years and a month ago
Posted in : Java Beginners


a java program to print

                           *
                         *   *
                       *   *   *
                     *   *   *   *
                       *   *   * 
                         *   *
                           *

Advertisement
View Answers

March 31, 2011 at 1:32 PM


public class PatternExample {
public static void main(String[] args) {
int num=3;
int p = num;
int q = 0;
for (int i = 0; i <= num; i++) {
for (int j = p; j>= 1; j-- )
System.out.print(" ");
p-=1;
for (int k = 1; k <= i; k++)
System.out.print ("* ");
System.out.println();
}
num-=1;
for (int i = 0; i<=num; i++) {
for (int j = num; j > i; j--)
System.out.print (" *");
System.out.println();
for (int k = 0; k <= q; k++)
System.out.print(" ");
q+=1;
}
}
}


Related Tutorials/Questions & Answers:
loop, control structures
loop, control structures  a java program to print
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
Advertisements
loop, control statements
loop, control statements  a java program to print
Loop Control flow enhancement discussion - Java Tutorial
Loop Control flow enhancement discussion 2001-04-28 The Java Specialists... next issue reminding people that Exceptions are not meant to be used as Loop control / Loop Control flow enhancement. I could see someone putting your switch
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
for loop
it is infinite loop. Java provides several loop structures for iteration. Those... the program control enters the loop it first does the initialization part... control will never return to the initialization part of the "for" loop when
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
Loop
to understand a loop my quesiton are: what du i do wrong in my code since its endless. i would like to control the "start" stop" and step from an object. (made in blueJ) Class Loop public void loopUpGeneral(int start, int stop
loop
loop  what is the difference b/w do while,while and for loop..with example
loop
loop  i want to write my name(inder) through loop in java using star
For loop
For loop  Hi! Please explain the following loop: for(i=0;i<a[j];i++) THANX!!   Please reply as soon as possible
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
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
SQL Simple LOOP
repeatedly until it push the flow of control to outside of the loop.... The Loop run repeatedly until it push the flow of control to outside... SQL Simple LOOP      
For Loop
For Loop  Write a program using a for loop that computes the following sum: 1/2 + 2/2 + 3/2 + 4/2 + 5/2 + ... N/2 N will be an integer limit the user enters. This is an example of my upcoming quiz. I need help on knowing
loop
loop  strong textHello can someone help me with this problem,I need 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
for loop
for loop  using only two for loop how can print below numbers 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 6 6 6 6 6 6 5 5 5 5
for loop
for loop  using only two for loop how can print below numbers 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 6 6 6 6 6 6 5 5 5 5
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
for loop in java example
.style1 { color: #0000FF; } for loop in java example We are going to discuss about for loop in java example. The for loop statement has type loop control statement. We first initialize the variable. After that check
do while loop
do while loop       In java a do while loop is a control flow statement that allows a certain code to be executed repeatedly based on a given condition. This loop is used in java
While Loop in JSP
While Loop in JSP          The while loop is a control flow statement.... In while loop the condition is firstly evaluated, if it finds that the condition
Java Software Structures
Java NotesJava Software Structures Java Software Structures: Designing and Using Data Structures, 2/E, by John Lewis and Joseph Chase. Addison Weseley, 2005 Errata, Lacunae, etc p 33 - Erroneously uses new with String
Flow Control Constructs
Flow Control Constructs       Flow Control Constructs include the IF, CASE, LOOP, WHILE, ITERATE... (0.01 sec) LOOP Statement The general syntax of LOOP Statement is :  
Ford and Topp, Data Structures with Java, Errata
Java NotesFord and Topp, Data Structures with Java, Errata This is a list of some of the errors that have been found in the process of teaching a data structures course from it. Chapter 1 Copyleft 2006 Fred Swartz MIT
Java Data Structures
Java NotesJava Data Structures Term "Collections". The overall term... to the more common Data Structures. In addition to describing general data... that professional programmers implement basic data structures, such as linked lists
Alternative Data Structures
Java NotesAlternative Data Structures Packages have been developed outside of Sun for additional functionality. The following free, GPL, packages fill... shortcomings of the Java Collections data structures: lack of support for primitive data
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
Use while loop in jsp code
Use while loop in jsp code       While loop is a control flow statement that works repeatedly based on a given boolean condition, loop will continuously execute
JSP for loop Example
JSP for loop Example In this section we will discuss about for loop in JSP. In every programming languages for loop is used. The for loop statement provide... will illustrate how to use for loop in JSP. Example : In this example we are going
For..in loop
For..in loop         In this tutorial we will study for..in loop which is similar to for each loop of C#, Java and other popular languages, in this example
calender control
calender control  plz tell me about calender type control in java
Session control
Session control  Could we make session control in JSP language without having any help of other framework
Java for loop
Java for loop  Can a for statement loop indefinitely
Loop in java
Loop is the control statement of any language in which whenever you want to perform the repetitious work then you use the Loop control statement. There are mainly three types of loops. Loop repeats a statement or a process multiple times
For Loop - Struts
For Loop  Hi, How to use for loop in Struts2. I don't want use.... How to use the For loop in JSP. Thanks, Rajesh.  Hi Rajesh, i am sending simple use of for loop. In this example, you will see the use
Limits of "For loop"
Limits of "For loop"  Hi, How can I check the upper limit and lower limit of 'FOR' loop during unit testing using Junit. Thanks & Regards Ankit
for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind
for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind
How to write a loop and a while loop
How to write a loop and a while loop  How do I write a 1 loop and a 1 while loop for the example code: public boolean isTheFirstOneBigger (int num1, int num2) { if (num1 > num2) { return true
loop statements
loop statements  write a program that reads from input an interger n and prints the factorial of all numbers between 1 and n
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
loop example
loop example   1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 can you give me the code to get the number pyramid
For Loop/PHP
For Loop/PHP  Write a class called math. It is to have one property... 12345. How would you write this as a loop? Would I need to use the for loop or do/while loop?   PHP Factorial Example: <?php $n = 5; $i = 1; $f
Advertisements
 

 

 

DMCA.com