loop, control structures

loop, control structures

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 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
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
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
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
SQL Simple LOOP
that are executed repeatedly until it push the flow of control to outside of the loop... the flow of control to outside of the loop.  Create Procedure... SQL Simple LOOP      
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
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
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
structures
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
looping structures in JavaScript
looping structures in JavaScript  What looping structures are there in JavaScript
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
ModuleNotFoundError: No module named 'structures'
ModuleNotFoundError: No module named 'structures'  Hi, My Python... 'structures' How to remove the ModuleNotFoundError: No module named 'structures' error? Thanks   Hi, In your python environment you
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
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
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
ModuleNotFoundError: No module named 'data-structures'
ModuleNotFoundError: No module named 'data-structures'  Hi, My... named 'data-structures' How to remove the ModuleNotFoundError: No module named 'data-structures' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'nested_structures'
ModuleNotFoundError: No module named 'nested_structures'  Hi, My... named 'nested_structures' How to remove the ModuleNotFoundError: No module named 'nested_structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'nested_structures'
ModuleNotFoundError: No module named 'nested_structures'  Hi, My... named 'nested_structures' How to remove the ModuleNotFoundError: No module named 'nested_structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pygen-structures'
ModuleNotFoundError: No module named 'pygen-structures'  Hi, My... named 'pygen-structures' How to remove the ModuleNotFoundError: No module named 'pygen-structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pygen-structures'
ModuleNotFoundError: No module named 'pygen-structures'  Hi, My... named 'pygen-structures' How to remove the ModuleNotFoundError: No module named 'pygen-structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pyriodic-structures'
ModuleNotFoundError: No module named 'pyriodic-structures'  Hi, My... named 'pyriodic-structures' How to remove the ModuleNotFoundError: No module named 'pyriodic-structures' error? Thanks   Hi
ModuleNotFoundError: No module named 'pyriodic-structures'
ModuleNotFoundError: No module named 'pyriodic-structures'  Hi, My... named 'pyriodic-structures' How to remove the ModuleNotFoundError: No module named 'pyriodic-structures' error? Thanks   Hi
ModuleNotFoundError: No module named 'py-structures'
ModuleNotFoundError: No module named 'py-structures'  Hi, My... 'py-structures' How to remove the ModuleNotFoundError: No module named 'py-structures' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'py-structures'
ModuleNotFoundError: No module named 'py-structures'  Hi, My... 'py-structures' How to remove the ModuleNotFoundError: No module named 'py-structures' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'redis_structures'
ModuleNotFoundError: No module named 'redis_structures'  Hi, My... named 'redis_structures' How to remove the ModuleNotFoundError: No module named 'redis_structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'aa-structures'
ModuleNotFoundError: No module named 'aa-structures'  Hi, My... 'aa-structures' How to remove the ModuleNotFoundError: No module named 'aa-structures' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'bm_structures'
ModuleNotFoundError: No module named 'bm_structures'  Hi, My... 'bm_structures' How to remove the ModuleNotFoundError: No module named 'bm_structures' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'data-structures'
ModuleNotFoundError: No module named 'data-structures'  Hi, My... named 'data-structures' How to remove the ModuleNotFoundError: No module named 'data-structures' error? Thanks   Hi, In your python
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
Flow Control Constructs
Flow Control Constructs       Flow Control Constructs include the IF, CASE, LOOP, WHILE, ITERATE... in set (0.00 sec) Query OK, 0 rows affected (0.01 sec) LOOP Statement
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
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
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
SQL Simple LOOP
repeatedly until it push the flow of control to outside of the loop... type to int. The Loop run repeatedly until it push the flow of control... SQL Simple LOOP      
ModuleNotFoundError: No module named 'external-data-structures'
ModuleNotFoundError: No module named 'external-data-structures'  Hi...: No module named 'external-data-structures' How to remove the ModuleNotFoundError: No module named 'external-data-structures' error? Thanks  
ModuleNotFoundError: No module named 'py-data-structures'
ModuleNotFoundError: No module named 'py-data-structures'  Hi, My... named 'py-data-structures' How to remove the ModuleNotFoundError: No module named 'py-data-structures' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pythonic-data-structures'
ModuleNotFoundError: No module named 'pythonic-data-structures'  Hi...: No module named 'pythonic-data-structures' How to remove the ModuleNotFoundError: No module named 'pythonic-data-structures' error? Thanks  
ModuleNotFoundError: No module named 'pythonic-data-structures'
ModuleNotFoundError: No module named 'pythonic-data-structures'  Hi...: No module named 'pythonic-data-structures' How to remove the ModuleNotFoundError: No module named 'pythonic-data-structures' error? Thanks  
ModuleNotFoundError: No module named 'pythonic-data-structures'
ModuleNotFoundError: No module named 'pythonic-data-structures'  Hi...: No module named 'pythonic-data-structures' How to remove the ModuleNotFoundError: No module named 'pythonic-data-structures' error? Thanks  
ModuleNotFoundError: No module named 'rtc-tools-hydraulic-structures'
ModuleNotFoundError: No module named 'rtc-tools-hydraulic-structures' ...: No module named 'rtc-tools-hydraulic-structures' How to remove the ModuleNotFoundError: No module named 'rtc-tools-hydraulic-structures' error

Ads