Home Answers Viewqa Java-Beginners loop, control structures

 
 


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

a java program to print

                           *
                         *   *
                       *   *   *
                     *   *   *   *
                       *   *   * 
                         *   *
                           *
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 Pages:
loop, control structures
loop, control structures  a java program to print
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
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 statements
loop, control statements  a java program to print
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
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 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
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      
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
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
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 :  
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
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
looping structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
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      
Iteration without loop
Iteration without loop  Hi, Is there any way I can have a line of code iterate a number of times set by the user without having a while loop or any other control statements? Thanks!   import java.util.*; class
While Loop
While Loop       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. 
PHP Alternative Control Structure
Alternative Control Structure: PHP provides alternative ways to use control structures like if, else, elseif, for, while, foreach etc. In each control... coding within any control structure, the examples are given below: elseif
For-each Loop
Java NotesFor-each Loop Purpose The basic for loop was extended... the for-in loop. Use it in preference to the standard for loop if applicable... of values. The for-each loop is used to access each successive value
PHP For Loop
For Control Structure: In for loop construct there are three parts of For loop, first Initialization part: initialize a variable (we can initialize more... increment or decrement the variable(s). Format of for loop is as below: for(variable
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
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
Java break for loop
control outside the outermost loop.           Break... Java break for loop       Example below demonstrates the termination of for loop under label
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
Java Break out of for loop
in stopping the program  control flowing inside the loop and bringing... Java Break out of for loop       In loop programming the program flow is continued till
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
Java Control Statements
program control immediately after the end of a loop and the continue statement is used to force program control back to the top of a loop. ... Java Control Statements      
Java Control Statements
. When the expression results to false control comes out of loop... statements. When i is greater than value 10 control comes out of loop and next... than number "10" so control goes inside of the loop and prints
Summary - Control Flow
Java: Summary - Control Flow Each control statement is one logical...: statements // do these if expr != any above } while loop... or some other statement (break or return) stops the loop. while
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
for-each loop in java
for-each loop in java In this section you will learn about for-each loop in java. for-each is a control statement which is used to traverse an array or object. for-each loop is used to iterate over array or collection object as well
Using "Case" control in JRuby
Using "Case" control in JRuby ... you have learned to use for-loop in JRuby. Now we will discuss that how to use "Case" control in our program to provide working of program on selected
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
PHP While Loop
While Control Structure: While is the simplest form of loop. While loop checks..., and become infinite loop. While loop is also known as pre-test loop. Basic format of while loop is as follows: while(condition) expressions
C Structure example
; This section illustrates you the concept of structure in C. Structures... or control blocks. A structure is a collection of variables grouped together under... id; char *name; float percentage; }   In structures, we have
Control Flow Statements in java 7
Control Flow Statements in java 7 In this section we will discuss Control Flow Statements in java 7. This is one type of Language Fundamentals. Control... but you can also control flow of your program with the help of control flow
While Loop Statement in java 7
. You can use any counter to iterate the loop. This type of control structure...While Loop Statement in java 7 This tutorial, helps you to understand the concept of while loop  in java 7. While Loop Statements : While loop
PHP Do While Loop
Do-While Control Structure: Do-While loop is another type of loop which runs at least once, since this loop checks the condition after executing the code... at least once despite of the validity of the variable. In Do-While loop we need
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
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
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