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 5 months 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
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
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
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
loop
loop  what is the difference b/w do while,while and for loop..with example
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... type to int. The Loop run repeatedly until it push the flow of control... 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
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 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
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 :  
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
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
calender control
calender control  plz tell me about calender type control in java
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
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
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 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
loop program
loop program  please tell me the code for the output 1 2 3foo 4 5bar 6foo 7baz 8 9foo 10 11 12foo 13 14baz 15foo bar 16 17 18foo . .......till 50
For loop java
For loop java  1 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 3 4 5 4 5 6 7 5 6 7 8 9 6 7 8 9 10
for loop in java
for loop in java  1 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 3 4 5 4 5 6 7 5 6 7 8 9 6 7 8 9 10 using for loop in java   Java Number Pattern 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 public class PatternExample{ public static void main
foreach loop in php
foreach loop in php  Foreach loop in php
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
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 array loop while
php array loop while  Using the php array while loop
php array loop count
php array loop count  Count the array using loop in php
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
Struts control data flow
Struts control data flow  How Struts control data flow
Java break for loop
control outside the outermost loop.           Break... Java break for loop       Example below demonstrates the termination of for loop under label
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
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
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
php array loop foreach
php array loop foreach  Display the php array elements in foreach loop
Java Loop - Java Beginners
Java Loop   WAP to print d following pattern wid d help of any loop(for or while or do-while
Infinite loop in c
Infinite loop in c   When i type my variable as a uint32_t, it returns the infinite loop why? uint32_t i
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
Advertisements
 

 

 

DMCA.com