loop, control structures

Ads
 

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;
}
}
}

Ads









Related Tutorials/Questions & Answers:
loop, control structures
loop, control structures  a java program to print
loop, control statements
loop, control statements  a java program to print
Advertisements
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
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
SQL Simple LOOP
that are executed 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      
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
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
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
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
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
structures
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
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
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
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
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

Ads