Pyramid Sequence
1
1 2
1 2 3
1 2 3 4
class Pyramid1
{
public static void main(String args[])
{
int i,j;
for(i=1;i< =4;i++)
{
for(j=1;j< =i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
}
}
/********* OUTPUT ********
1
1 2
1 2 3
1 2 3 4 */
Subscribe to:
Post Comments (Atom)
I want the answer of:
1
12
123
12
1
here is the code :
class Pyramid1
{
public static void main(String args[])
{
int i,j;
for(i=1;i< =3;i++)
{
for(j=1;j< =i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
for(i=2;i> =1;i--)
{
for(j=1;j< =i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
}
}
how do you do this?
1
121
12321
1234321
123454321
12345654321
123454321
1234321
12321
121
1
@calvin
here is the code :
i think it should work
class Pyramid1
{
public static void main(String args[])
{
int i,k,j;
for(i=1;i< =6;i++)
{
for(j=1;j< =i;j++)
System.out.print(" "+j);
for(k=i-1;k> =1;k--)
System.out.print(" "+k);
System.out.print("\n");
}
for(i=5;i> =1;i--)
{
for(j=1;j< =i;j++)
System.out.print(" "+j);
for(k=i-1;k> =1;k--)
System.out.print(" "+k);
}
}
}
Above code is not proper working..............
Can you help me please!!
I want the answer of :
1
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
Hi! I'm a beginner in Java can you please give a sample code for this:
0
90
890
7890
67890
567890
4567890
34567890
234567890
1234567890
i want answer of:
*
* *
* * *
* * * *
hi i need code for the output
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
hi
i want this output
4
3 4 3
2 3 4 3 2
1 2 3 4 3 2 1
hi
i want this output
4
3 4 3
2 3 4 3 2
1 2 3 4 3 2 1
hi
i want this output
4
3 4 3
2 3 4 3 2
1 2 3 4 3 2 1
class Loop
{
public static void main (String args[])
{
for
(int i=1; i<=9; i++)
{
for
(int j=1; j<=i; j++)
{
System.out.print("");
System.out.print(*);
}
System.out.print("\n");
}
System.out.println ("\n");
}
}
i want a program to print
1
2 3
4 5 6
7 8 9 10
Write a java program to print
123
456
789
Write a java program to print
123
456
789
hw if using the 'do while' loop?
I want answer to this pls...
1
222
33333
4444444
555555555
@abey:
class Pyramid{
public static void main(String args[]){
int i,k,j;
for(i=1;i<=128;i= i*2){
for(j=1; j<=i; j=j*2)
System.out.print(j + " ");
for(k=i/2; k>=1; k=k/2)
System.out.print( k + " ");
System.out.print("\n");
}
}
}
how to make as java program using for loop that will look like this
1
121
12321
1234321
123454321
need it on wednesday
hi..i am ikko...
how can i get this result frmo a java program??
----------------------1
--------------------1 2 1
------------------1 2 4 2 1
----------------1 2 4 8 4 2 1
-------------1 2 4 8 16 8 4 2 1
---------1 2 4 8 16 32 16 8 4 2 1
------1 2 4 8 16 32 64 32 16 8 4 2 1
--1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
public static void count(int n) {
int s = 1;
for (int i = 1; i <= n; i++) {
while (s <= i) {
System.out.print(s);
s++;
}
s--;
while (s > 1) {
System.out.print(--s);
}
System.out.println();
}
}
//output for this one:
1
121
12321
1234321
etc. etc.
public static void value_times_two(int n) {
int s, p;
s = 1;
p = 1;
for (int i = 1; i <= n; i++) {
p = 1;
System.out.print(p);
while (s <= i) {
System.out.print(p *= 2);
s++;
}
while (s > 1) {
System.out.print(p /= 2);
--s;
}
System.out.println();
}
}
//expected output for this one is as follows:
1
121
12421
1248421
etc. etc.
hi..
Can anyone give me code for below output...??
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
i need a code for this program :]
kindly help me thanks .
1
232
34543
4567654
567898765
how to create triangle of numbers in this type of form:
output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*
* *
* * * *
* * * * * * * *
I want the answer of :
*
* *
* * * *
* * * * * * * *
i want the answer for this
1
22
333
4444
55555
6666
777
88
9
i need code for this
1
22
333
4444
55555
6666
777
88
9
hey tom code fr
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6
7 7 7
8 8
9
class Pyramid1
{
public static void main(String args[])
{
int k;
//for loop for the no of lines to print till 55555
for(int i=1;i<=5;i++)
{
System.out.println();
//for loop for printin da nos
for(int j=1;j<=i;j++)
{
k=i;
System.out.print(k);
}
}
//making k=6 to start printin 6666 after 55555
k=6;
for(int i=1;i<=4;i++)
{
//to change the line
System.out.println();
for(int j=4;j>=i;j--)
{
System.out.print(k);
}
k++;
}
}
}
hope it helps u,i hav tried it nd it works.
I want code of
1 1
12 21
123 321
12344321
123 321
12 21
1 1
I want code of
1 1
12 21
123 321
12344321
123 321
12 21
1 1
can i have the code for
...........0
..........101
.........21012
........3210123
.......432101234
Program for this
1
212
32123
4321234
543212345
4321234
32123
212
1
Please fast
i m anjali...
i get solution of this problem
**
****
******
********...plz help me
1
12
123
1234
this output program i could not understand please explain this program for pyramid.
code for
1
2 2
3 3 3
i want d answer for
1
2 2
3 3 3
4 4 4 4
4 4 4 4
3 3 3
2 2
1
i want this answer of
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
i want this answer of
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
i want this answer of
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
ENTER num 1 :
ENTER num 2:
"MULTIPLICATION TABLE " ANY NUMBER WILL DO..
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
ENTER num 1 :
ENTER num 2:
"MULTIPLICATION TABLE " ANY NUMBER WILL DO..
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
ENTER num 1 :
ENTER num 2:
"MULTIPLICATION TABLE " ANY NUMBER WILL DO..
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
ENTER num 1 :
ENTER num 2:
"MULTIPLICATION TABLE " ANY NUMBER WILL DO..
anybody here knows the program of this problem
543212345
5432 2345
543 345
54 45
5 5
hi...
i need code to print
0 100
1 99
2 98
.
.
.
.
100 0
99 1
98 2
....
in an infinite loop
using single loop and single variable......
hi...
i am pranav
i need the code to print
0 100
1 99
2 98
.
.
.
100 0
99 1
98 2
.
.
.
.
in an infinite loop using single loop and single variable.....
i want like this code
---------1
---------22
--------333
--------4444
public class pry {
public static void main(String[] args) {
int myLevel;
int i, j , k;
myLevel = 6;
for (i = 1; i <= myLevel; i++) {
for (k =1; k <= myLevel-i; k++)
System.out.print(" ");
for (j = k+1; j <=myLevel; j++)
System.out.print( "*");
for(int l=myLevel;l>k-1;l--)
System.out.print( "*");
System.out.println("");
}
}
}
OUTPUT:-
-------*
------***
-----*****
----*******
---*********
--***********
class h
{
public static void main(String[] args) {
int myLevel;
int i, j , k;
int x=1;
myLevel = 6;
for (i = 1; i <= myLevel; i++) {
for (k =1; k <= myLevel-i; k++)
System.out.print(" ");
for (j = k+1; j <=myLevel; j++)
System.out.print(x);
for(int l=myLevel;l>k-1;l--)
System.out.print(x);
x++;
System.out.println("");
}
}
}
OUTPUT:-
-------1
------222
-----33333
----4444444
---555555555
--66666666666
I want the ans of
1
01
101
0101
10101
public class Pyramid {
public static void main(String[] args) {
int n;
int i, k, a, m, j;
m = 6;
for (a = 1; a <= m; a++) {
for (i = 1; i < n; i++) {
System.out.print(" ");
}
for (k = 1; k <= a; k++) {
System.out.print(k);
}
for (j = k - 1; j > 1; j--) {
System.out.print(j - 1);
}
System.out.print("\n");
n = n - 1;
}
}
}
OUT PUT
1
121
12321
1234321
123454321
12345654321
I want answer for the following output
1
1 1
1 1 1 1
1 1
1
i want this output.if you known means please share with me
1
2 3
4 5 6
7 8 9 10
i want this output.if you known means please share with me
1
2 3
4 5 6
7 8 9 10
Hi i need a code for the following.
1
2 3 2
4 5 6 5 4
7 8 9 10 9 8 7
I want the code for the following program:
1 :sum = 1
1 2 :sum =3
1 2 3 : sum = 6
1 2 3 4 :sum =10
.
.
.
.
hi..
Can anyone give me code for below output...??
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
hi..
Can anyone give me code for below output...??
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
how to print the following triangle?
1
23
456
79-----91
hi to all can you help me with this program, i need a code that diplays a pyramid of asterisk.. using only the integer row and column please help needed badly.
public static void main(String[] args) {
int i,j,k;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5-i; j++)
System.out.print(" ");
for(k=j; k<=5; k++){
System.out.print("*");
System.out.print(" ");}
System.out.println();
}
}
}
output:
*
* *
* * *
* * * *
* * * * *
public static void main(String[] args) {
int i,j,k;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5-i; j++)
System.out.print(" ");
for(k=j; k<=5; k++){
System.out.print("*");
System.out.print(" ");}
System.out.println();
}
}
}
output:
*
* *
* * *
* * * *
* * * * *
* *
*** ***
***********
i want this code
Code for
1
1 2
1 2 3
1 2 3 4 :
Code:
public class Pramid_test1 {
public static void main(String[] args) {
int noOfRows = 10;
for(int i = 1; i < noOfRows;i++)
{
for(int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Solution For:
1
1 2
1 2 3
1 2 3 4
public class Pramid_test1 {
public static void main(String[] args) {
int noOfRows = 10;
for(int i = 1; i < noOfRows;i++)
{
for(int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Solution For:
1
12
123
12
1
public class Pyramid_test2 {
public static void main(String[] args) {
int noOfRows = 9;
double center = Math.ceil((Double)(noOfRows+0.0)/2);
for (int i = 1; i <= noOfRows; i++) {
int j = 1;
while(j <= i) {
if(j <= center)
{
System.out.print(j);
if(j == center)
{
center = center - 1;
}
j++;
}
else
{
break;
}
}
System.out.println();
}
}
}
Solution for:
1
121
12321
1234321
123454321
12345654321
123454321
1234321
12321
121
1
public class Pyramid_test3 {
public static void main(String[] args) {
int noOfRows = 9;
double center = Math.ceil((Double)(noOfRows+0.0)/2);
for (int i = 1; i <= noOfRows; i++) {
int j = 1;
while(j <= i) {
if(j <= center)
{
System.out.print(j);
if(j == center || j == i)
{
for(int k=j-1; k>=1;k--)
{
System.out.print(k);
}
if(j == center)
{
center = center - 1;
}
}
j++;
}
else
{
break;
}
}
System.out.println();
}
}
}
Solution For:
1
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
public class Pyramid_test4 {
public static void main(String[] args) {
int noOfRows = 7;
for (int i = 1; i <= noOfRows; i++) {
int pr = 1;
for(int j = 1; j < 2*i; j+=2)
{
System.out.print(pr+" ");
if(j == 2*i - 1)
{
int rep = pr/2;
for(int k=j-1; k >=1; k-=2)
{
System.out.print(rep+" ");
rep/=2;
}
}
pr*=2;
}
System.out.println();
}
}
}
i want the answer for
*
* *
* * *
* * * *
* * *
* *
*
i want the answer for
*
* *
* * *
* * * *
* * *
* *
*
this is very nice question
want the Code For
w w w w
w w w w w w
w w w
I need the code for an upside down * triangle. So far I came up with the program to do it right side up.
***********
*********
*******
*****
***
*
...
how can i get this result frmo a java program??
1
1 1
1 2 2 1
1 3 4 3 1
1 4 7 7 4 1
iwant code for d given program
1
1 1
1 2 2 1
1 3 4 3 1
1 4 7 7 4 1
How can i get this? Thanks for help (without (-) in this picture :))
----|
---*|*
--**|**
-***|***
****|****
How could i write this, that only tvo lines and rows are written with stars and in the middle it shoul be empty space. (it is square a by b, or just a)
*******
*******
** **
** **
*******
*******
a= length
b= height
*
* * *
* * * * *
* * *
*
Plz help me
package basics;
public class Demo5
{
public static void main(String a[])
{
int i,j,cnt=1,check=0;
for(i=1;i<=10;i++)
{
System.out.print(i);
check++;
if(check==cnt)
{
System.out.println();
cnt++;
check=0;
}
}
}
}
if i am creating a pyramid like
*
* * *
* * * * *
* *
* *
* *
*
* *
* *
* *
pleas try this i can not done this in c or java...
I want to print star like shown below
* * * *
* * *
* *
*
can you please help me as soon as possible before monday,thnks
I want output like this
* * * *
* * *
* *
*
please ,please help me
i want output like this
* * * *
* * *
* *
*
please help me,thank you
1234321
123 321
12 21
1 1
please,give me this pattern in java
1234321
123 321
12 21
1 1
please,give me this pattern in java
1234321
123 321
12 21
1 1
please,give me this pattern in java
can anyone solve for this
INPUT : 1WshT%&Dsd
OUTPUT: DSd&%tHSw1
reverse then my problem is how to solve the uppercase-lowercase logic
U-U-L-L-U-L-U-U-L-L
WHERE: U = UPPER & L = LOWER
can anyone solve for this
INPUT : 1WshT%&Dsd
OUTPUT: DSd&%tHSw1
reverse then my problem is how to solve the uppercase-lowercase logic
U-U-L-L-U-L-U-U-L-L
WHERE: U = UPPER & L = LOWER
can anyone solve for this
INPUT : 1WshT%&Dsd
OUTPUT: DSd&%tHSw1
reverse then my problem is how to solve the uppercase-lowercase logic
U-U-L-L-U-L-U-U-L-L
WHERE: U = UPPER & L = LOWER
can anyone solve for this
INPUT : 1WshT%&Dsd
OUTPUT: DSd&%tHSw1
reverse then my problem is how to solve the uppercase-lowercase logic
U-U-L-L-U-L-U-U-L-L
WHERE: U = UPPER & L = LOWER
I want the answer like below..thanks in advance
1
123
12345
1234567
123456789
can sm1 help me with dis:
abcddcba
abc cba
ab ba
a a
ab ba
abc cba
abcddcba
can sm1 help me wid dis:
abcddcba
abc<>cba
ab<><>ba
a<><><>a
ab<><>ba
abc<>cba
abcddcba
hi please help me.I want following output
String str ="WELCOME";
C
E L O
W E L O M
Please help me
I want following output
String str="WELCOME";
O/P:
C
L C O
E L C O M
W E L C O M E
String str = "WELCOME";
I WANT O/P LIKE
C
L C O
E L C O M
W E L C O M E
plz help me advance in thanks
Hiee plz help me to find the code of
1
4 2
3 3 3
4 4 4 4
Hiee plz help me to find code of:
1
4 2
3 3 3
4 4 4 4
hi! can somebody help me? can someone teach me the code for this output..
123454321
1234321
12321
121
1
hi! can someone help me with this output??
123454321
1234321
12321
121
1
thank you in advance....
* * * * * * *
* * * s * * *
* * s s s * *
* s s s s s *
how to print this
Plz can sm1 help me with this
***********
***** *****
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
***** *****
***********
54321
5432
543
54
5
i want this type of program
54321
5432
543
54
5
i want this type of program
hi im shreyas
i need a program for:-
1
121
12321
1234321
123454321
using nested for loop
please somebody help me.
hi im shreyas
i needa program for:-
1
121
12321
1234321
123454321
USING NESTED FOR LOOP.
PLZ SOMEONE HELP ME.
hi im shreyas
i needa program for:-
1
121
12321
1234321
123454321
USING NESTED FOR LOOP.
PLZ SOMEONE HELP ME.
i want a code for
1
21
321
4321
54321
i want a code for
1
21
321
4321
54321
What is the java code for this one ?
P
*R
**O
***G
****R
*****A
******M
*******M
********I
*********N
**********G
ans. for this
0 0
2 4 1 3
6 8 10 5 7 9
12 14 16 18 11 13 15 17
can someone tell me the code of this:
1
22
333
4444
55555
can someone tell me the program of this:
1
22
333
4444
55555