1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
/* Java Pyramid 3 Example This Java Pyramid example shows how to generate pyramid or triangle like given below using for loop. * ** *** **** ***** ***** **** *** ** * */ public class JavaPyramid3 { public static void main(String[] args) { for(int i=1; i<= 5 ;i++){ for(int j=0; j < i; j++){ System.out.print("*"); } //generate a new line System.out.println(""); } //create second half of pyramid for(int i=5; i>0 ;i--){ for(int j=0; j < i; j++){ System.out.print("*"); } //generate a new line System.out.println(""); } } } /* Output of the example would be * ** *** **** ***** ***** **** *** ** * */ |
sir can i favor to you please give me a code, i want to request to you to give me a code of this program using bufferedreader by for loops. the program to be like this: TO BE diamond pattern
*
**
***
****
*****
****
***
**
*
class Pyramid3{
public static void main(String st[]){
int i,j;
for(i=1;i<=5;i++)
{
for(j=0;j<i;j++) {=”” system.out.println(“*”);=”” }=”” system.out.println(“=”” “);=”” }=”” for(i=”4;i”>0;i–)
{
for(j=0;j<i;j++) {=”” system.out.println(“*”);=”” }=”” system.out.println(“=”” “);=”” }=”” }=”” }=””>
for (int i=1; i<=5; i++){
for(int x=i; x<=i; x++){
System.out.print(“*”);
}
System.out.printla ();
}
for (int r=1; r<=4; r++){
for(int y=5; y>=r; y–){
System.out.print(“*”);
}
System.out.printla ();
}
sir can i favor to you please give me a code, i want to request to you to give me a code of this program using bufferedreader by for loops. the program to be like this: TO BE diamond pattern
*
* *
* * *
* * * * * *
for(int z = 0 ; z <=4 ; z ++)
{
for(int x = 0 ; x <= z ; x ++)
{
if(x>2)
{
}
else
{
System.out.print(“*”);
}
}
if(z>2)
{
System.out.print(“”);
}
else
{
System.out.println(“”);
}
}
sir can you give me the program which the output is a triangle?
Sir/madam,
i want pyramid like this
*
***
*****
*******
*********
please help me…
for(int i=1; i<=5; i++){
for(int j=1; j<=i*2; j++){
System.out.print(“*”);
}
System.out.println();
}
import java.io.*;
class prmd2
{
public static void main(String args[])
{
System.out.println(“dhana pyramid”);
for(int i=0;i<=5;i++)
{
for(int j=0;j<i*2-1;j++) system.out.print(“*”);=”” system.out.println();=”” }=”” }=”” }=””>
anyone who can help me to create this program..
*****
****
***
**
*
*
**
***
****
*****
thanks..
for(int z = 5 ; z >= 0 ; z–)
{
for(int x = 0 ; x <=z ; x++ )
{
System.out.print(“*”);
}
System.out.println(“”);
}
for(int z = 0 ; z <= 5 ; z ++)
{
for(int x = 0 ; x <=z ; x++)
{
System.out.print(“*”);
}
System.out.println(“”);
}
for (int i=5; i>=1; i–){
for(int x=1; x<=i; x++){
System.out.print(“*”);
}
System.out.printla ();
}
for (int r=0; r<=3>; r++){
for(int y=0; y<=r+1; y++){
System.out.print(“*”);
}
System.out.printla ();
}
import java.io.*;
class prmd
{
public static void main(String args[])
{
for(int i=0;i<5;i++)
{
for(int j=i;j<5;j++)
System.out.print(“*”);
System.out.println();
}
for(int i=0;i<5;i++)
{
for(int j=0;j<i+1;j++) system.out.print(“*”);=”” system.out.println();=”” }=”” }=”” }=””>
how to print the same pyramid as
1
11
111
1111
this type can u help me any one?
for(int i=1; i<=4; i++){
for(int x=1; x<=i; x++){
System.out.print(“1”);
}
System.out.println();
}
sir. what is the code for this
* *
* *
* *
* *
*
its an inverted pyramid.
line spacing in the middle is 9,7,5,3
for(int i=1 ; i<=9 ; i++){
if(i%2==0){
System.out.printla(“*”);
}
else{
System.out.print(“*”);
}
}
how about forming a circle?? anyone?? who can help??
*
**
***
****
*****
****
***
**
*
sir code pls ?
public class JavaPyramid4 {
public static void main(String[] args) {
for(int i=1; i<= 5 ;i++){
for(int j=1; j <= i; j++){
System.out.print(“*”);
}
System.out.println(“”);
}
for(int i=4;i>=0;i–)
{
for(int j=1;j<=i;j++)
{
System.out.print(“*”);
}
System.out.println(“”);
}
}
}
Anyone who knows this code how we should write
*
* *
* ? *
* *
*
can u help me from this code
i want the code
i want diamond shape in middle any symbol should be there