Creating number or symbol patterns is used to check command of a programmer or a student on for loop. In short its done just for practicing for loop.
Here are some common number patterns :
Here are some common number patterns :
public class numPtr { public static void main( String arg[]){ for(int i=1;i<=5;i++){ for(int j=1;j<=i;j++){ System.out.print(j); } System.out.println(); } } }
Pattern 2.
To Print this pattern use the following code:
public class numPtr { public static void main( String arg[]){ for(int i=1;i<=5;i++){ for(int j=5;j>=i;j--){ System.out.print(j); } System.out.println(); } } }
Pattern 3.
To Print this pattern use the following code:
public class numPtr { public static void main( String arg[]){ for(int i=1,r=5;i<=5;i++,r--){ for(int j=1;j<=r;j++){ System.out.print(j); } System.out.println(); } } }
Pattern 4.
public class numPtr { public static void main( String arg[]){ int ck=0,c=2; while(c>0){ if(ck==0){ for(int i=1;i<=5;i++){ for(int j=1;j<=i;j++){ System.out.print(j); } System.out.println(); } ck++; } else{ for(int i=1,r=5-1;i<=5-1;i++,r--){ for(int j=1;j<=r;j++){ System.out.print(j); } System.out.println(); } } c--; } } }Pattern 5.
public class numPtr { public static void main( String arg[]){ int ck=0,c=2; while(c>0){ if(ck==0){ for(int i=1,r=5;i<=5;i++,r--){ for(int j=1;j<=r;j++){ System.out.print(j); } System.out.println(); } ck++; } else{ for(int i=2;i<=5;i++){ for(int j=1;j<=i;j++){ System.out.print(j); } System.out.println(); } } c--; } } }Author Note: All the above examples gives output till 5, you can change it accordingly by changing the conditions.
1223 Comments Leave new
«Oldest ‹Older 801 – 1000 of 1223 Newer› Newest»***** *****
Reply**** ****
*** ***
** **
*
This is the pattern for n=5.
Please provide the sourcecode in java.
my pattern is
Reply1 1 1 1 1
1 1 1 1 5
1 1 1 4 5
1 1 3 4 5
1 2 3 4 5
thanks anand
Replypublic static void main(String[] args)
Reply{
//int num=1;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.print(" ");
for(int k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
public static void main(String[] args)
Reply{
//int num=1;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.print(" ");
for(int k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
public static void main(String[] args)
Reply{
int num=1;
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
System.out.print(num+" ");
num++;
}
System.out.println();
}
}
public class Test2 {
Replypublic static void main(String[] args) {
int l=6;
for(int i=0; i<5; i++){
for(int j=1; j<6; j++){
if(l<=j && i!=0)
System.out.print(j);
else
System.out.print(1);
}
l--;
System.out.print("\n");
}
}
}
can u tell me the code for pattern
Reply1
1*2
1*2*3
1*2*3*4
1*2*3*4*5
WAP to create the following pattern:
Reply* * * *
* * *
* * * *
* * *
* * * *
* * *
* * * *
can you please solve this
plz help
Reply1
2 3 4
5 1 2 3 4
5 1 2 3 4 5 1
Sir
ReplyPlease help me to print the following
11
12 22
13 23 33
14 24 34 44
15 25 35 45 55
1
Reply3 5
7 9 11
public class Test4 {
Replypublic static void main(String[] args) {
int i=1;
int l=1;
for(int j=0; j<4; j++){
for(int k=0; k<l; k++){
System.out.print(i);
i++;
if(i==6)
i=1;
}
l=l+2;
System.out.print("\n");
}
}
}
please send the code for this pattern
Reply1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
6 7 8 9 0 1 0 9 8 7 6
7 8 9 0 1 2 3 2 1 0 9 8 7
8 9 0 1 2 3 4 5 4 3 2 1 0 9 8
sir please tell me the code of this
Reply1
22
333
4444
55555
1
Reply4
9
25
49
121
169
289
361,
.... i am ramakoti, sir please provide code and count count the digits which have 4
sir i want below pattern code and count the digits which have 4 digit
Reply1
4
9
25
49
121
169
289
361
529
841
961
1369.......n
sir please provide code for this pattern and count the no of digits which have 4 number
Reply1
4
9
25
49
121
169
289
361
529
841
961......N
import java.util.*;
Replyclass rightTriangle
{
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("");
}
}
}
code for the output::
Reply2
35
71113
17192329
3137414347
Sir plz tell me
ReplyA
A B
B C D
C D E F
D E F
E F
F
hi how do i code this in java?
Reply01
02 06
03 07 10
04 08 11 13
05 09 12 14 15
given that i accepted input from a user which is 5?
1111
Reply333
55
7
pls send code this patterns
15 10 6 3 1
Reply14 9 5 2
13 8 4
12 7
11
plzz tell the code for this
how to do this pattern?
Reply1
3 1
5 3 1
7 5 3 1
9 7 5 3 1
how to do this pattern?
Reply1
3 1
5 3 1
7 5 3 1
9 7 5 3 1
Reply soon plz
how to do this pattern?
Reply1
3 1
5 3 1
7 5 3 1
9 7 5 3 1
Reply soon plz
Sir,can you please solve the following pattern:
ReplyA
B
ABCBA
B
A
Please can I know the solution using only for loops
Reply1
21
321
4321
54321
654321
I know how to print those blank spaces and the number pattern indivisually but not together :(
please help!
Please can I know the solution using only for loops
Reply1
21
321
4321
54321
654321
I know how to print those blank spaces and the number pattern indivisually but not together :(
please help!
Could you help me with this program please?
Reply1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
please tell me this ?
Reply1 1
2 1
3 2
4 2
5 3
for(int i=1;i<=5;i++)
Reply{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
if(i!=5)
{
System.out.print(" ");
}
for(int j=i;j>=1;j--)
{
System.out.print(j);
}
System.out.println();
}
hey can you please guide me to get the pattern
Reply* * * * *
* *
* *
* *
* * * * *
sir i want output for this number pattern
Reply3 4 7
7 5 12
12 6 18
Hi,
ReplyUr blog is veryuseful for programmers.
I wanted for spiral matrix
5 6 7
4 9 8
3 2 1
Hi,
ReplyUr Blog is very useful and improves skills for an programmer
I am trying for an spiral matrix.. could u help it out
5 6 7
4 9 8
3 2 1
please help me to print this pattern
Reply1
3 5
7 9 11
*****
Reply*
*
*
code=?
*****
Reply*
*
*
code=?
55555
Reply64447
83339
55555
Reply64447
83339
55555
Reply64447
83339
Sir, please solve this problem.
Reply15
14 10
13 9 6
12 8 5 3
11 7 4 2 1
i am telling the output which i want:
ReplyEnter any sentence: abcd
* * * * * * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * * * * *
it is actually not like this
Replyits a big capital A B C D
__***___****___***__****
*-----*_*---*_*---*_*---*
*-----*_*---*_*_____*---*
*******_****__*_____*---*
*-----*_*---*_*_____*---*
*-----*_*---*_*---*_*---*
*-----*_**** __***__****
please provide me code about the given output.
Replyjjjjjjjjj aa v v aa
j a a v v a a
j a a v v a a
j a a v v a a
j a a v v a a
j a a v v a a
j a a v v a a
j a a a a a a a a v v a a
j a a v v a a a a a a a a a
j a a vv a a
how to output the following pattern in java
Reply1 2 3
4 5 6
7 8 9
Could you please help me find the code for this pattern?
Reply1
2
1 2 3 2 1
2
1
answer the following pattern
Reply1
24
135
2468
13579
1
Reply24
135
2468
13579
1
Reply24
135
2468
13579
Hi Zankar - find the code for your pattern
Replyclass Mysample
{
public static void main (String[] args)
{
for (int i=1;i<6;i++)
{
for (int j=1; j<=i; j++)
{
System.out.print(j);
}
System.out.print(" ");
for (int j=i; j>=1; j--)
{
System.out.print(j);
}
System.out.println();
}
}
}
Hi could u please tell me how to solve this pattern???
Reply5
45
345
2345
12345
class Mysample
Reply{
public static void main (String[] args)
{
for (int i=1;i<=6;i++)
{
for (int j=1;j<=6 ;j++)
System.out.print(i+" ");
else { System.out.print(i+1);}
c++;
} }
else {
for (int j=1;j<=6 ;j++)
{
if (j<=1)
System.out.print(i+1+" ");
else { System.out.print(i+" ");}
c--;
}
}
System.out.println();
}
}
}
1 2 3 4 5
Reply6 7 5 9
10 11 12
13 14
15
plz solve
Code for following output....
Reply567
498
321
Give me a code for this sir
Reply12345
1234
123
12
1
0000*
Reply000*0
00*00
0*000
*0000
How to code this sir??
class Mysample
Reply{
public static void main (String args[])
{ int c=10;
for(int i=4;i>=1;i--)
{
for(int j=1;j<=i;j++){
System.out.print(c-(i-j));}
c-=i;
System.out.println();
}
}
}
class Mysample
Reply{
public static void main (String args[])
{ int c=10;
for(int i=4;i>=1;i--)
{
for(int j=1;j<=i;j++){
System.out.print(c-(i-j));}
c-=i;
System.out.println();
}
}
}
Hello Sir, can u give me code for this pattern
Reply1
3 5
7 9 11
class Mysample
Reply{
public static void main (String args[])
{
for(int i=5;i>=1;i--)
{
for(int j=i;j<=5;j++)
{
System.out.print(j);
}
System.out.println();}
}
}
Sir can u help me with this ptterrn , its very difficult for me to solve
Reply1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
Can u help me to write generalized code. For this pattern
ReplyD
A D A
M A D A M
M A D A D A M
M A D A M A D A M
M A D A D A M
M A D A M
A D A
D
Sir i need code for this 1...
Reply1
9 4
10 7 2
14 12 8 5
15 13 11 6 3
sir can you help me in doing the program
Reply5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
Can u give the code for the following pattern??
Reply567
498
321
I want a java program which should display the following output .
Reply4321
1234
4321
1234
code for to print ?
Reply1¹ 2² 3³ 4⁴ 5^5
1¹ 2² 3³ 4⁴
1¹ 2² 3³
1¹ 2²
1¹
Please help me below pattern
Reply* * * * *
* * * *
* * *
* *
*
Please provide the code for below pattern
Reply1
1 2
3 5 8
132134
5589144233
sir can you give the coding for
Reply1
3 3
5 5 5
7 7 7 7
9 9 9 9 9
Input: 5 5, stands for 5 rows and 5 columns!
ReplyProduce the following pattern given the input:
11111
12221
12321
12221
11111
How to code this? Should be able to take any arbitrary input of rows and columns
What will be the code for this pattern
Reply1
2 3 2
4 5 6 5 4
7 8 9 0 9 8 7
1 2 3 4 5 4 3 2 1
6 7 8 9 0 1 0 9 8 7 6
2 3 4 5 6 7 8 7 6 5 4 3 2
1 2 3 4 5
Reply15 6
14. 7
13 8
12 11 10. 9
code for this program
1 2 3 4 5
Reply15 6
14. 7
13 8
12 11 10. 9
code for this program
1
Reply12
123
1234
12345
textname
textname
textname
textname
textname
process complete
HOW TO DO THAT ?
please tell me java code for
Reply####
##
$$$$$
**
****
can anyone help me with this program
Reply-------C
------CO
-----COM
----COMP
---COMPU
--COMPUT
-COMPUTE
COMPUTER
here - means space.the program should be written using forloop
Hai sir can you help me ? I want diplay a pattern with 's''y''a''z''a' in star pattern can you help me ?
Reply----------------------- 1
Reply--------------------2 15 3
------------------4 5 66 6 7
---------------8 9 10 189 11 12 13
pls solve this pattern
Hi Can you help me for this below pattern
Replya
ab
bac
abcd
cabde
eadcbf
How to print this 6 please help
Reply1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
@
@ @ @
@ @ @ @
@ @ @
Sir I want a java program which should display the following output
Reply1
3 5
7 9 11
Java Codings for Beginners with Examples
Reply1
Reply2 4
3 6 9
4 8 12 16
1
Reply2 4
3 6 9
4 8 12 16
1
Reply2 4
3 6 9
4 8 12 16
package module1;
Replypublic class Question_IO {
static int o = 1;
public static void main(String[] args) {
int i,j,k;
for ( i = 1; i <= 4; i++) {
for (j = i; j <= i; j++) {
for (k = 0; k <j; k++) {
System.out.print(o + " " );
o++;
}
}
System.out.println();
}
}
}
Code for this
Reply1
21
321
4321
54321
Code for this
Reply1
21
321
4321
54321
Code For
Replyinput Value = 5 (USING SCANNER)
1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4
1 2 3 4 5
help need code for this
Replythanks :)
1*********
12********
123*******
1234******
12345*****
123456****
1234567***
12345678**
123456789*
1234567890
10
Reply01010
101010
010101010
please exlain wid code for
Reply3 3 3
3 1 3
3 2 3
3 3 3
please exlain wid code for
Reply3 3 3
3 1 3
3 2 3
3 3 3
what will code of
Reply1
22
333
4444
55555
what will code of
Replyp
pr
pri
priy
priye
priyes
priyesh
what is the code for que. like this
Replyif we enter 5
1 2
5 4 3
and if we enter 8
7 8
6 1 2
5 3 4
and if we enter 16 then the output should be like this
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
1
Reply2 1
1 2 3
4 3 2 1
1 2 3 4 5
6 5 4 3 2 1
1 2 3 4 5 6 7
1
Reply2 1
1 2 3
4 3 2 1
1 2 3 4 5
6 5 4 3 2 1
1 2 3 4 5 6 7
please print this pattern for me
Reply0
909
89098
7890987
678909876
56789098765
can u help me to print the pattern using while loop
Reply1
12
123
1234
12345
I need this code
Reply1234567654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
I need this code
Reply1234567654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
******
Reply***** ***** For this?
**** ****
*** ***
** **
* *
1
Reply21
321
321
21
1
1
Reply21
321
321
21
1
Program for the pattern:
Reply*
*#
*#*
*#*#*
Help me sir for this pattern
Reply1
211
312
413
514
615
716
817
918
1019
20 this sequence continue UpTo 100 plzzz help me sir
A
ReplyBC
DEF
GHIJ
PLS GIVE CODE FOR THIS ASAP
Plz let me know this code....
Reply11
1221
123321
1221
11
1
121
12 21
12 21
12 21
121
1
1
Reply2 4
3 6 9
4 8 12 16
*
Reply* *
* * *
* * * *
how to generate this pattern?
i need the logic for following
Replyif input is 3, then the output is
7 8 9
6 1 2
5 4 3
and if the input is 4,
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
Sir please solve this
ReplyWAP TO PRINT
1
101
10101
1010101
DEAR SIR PLEASE FIND WAP TO PRINT THE FOLLOWING PATTERN USING TRY CATCH BLOCK
Replya) 1
101
10101
1010101
b) *
0 0
* * *
0 0 0 0
* * * * *
0 0 0 0
* * *
0 0
*
c) 1
1 2 1
1 3 3 1
1 4 6 4 1
15 10 10 5 1
DEAR SIR PLEASE FIND
ReplyWAP TO PRINT THE FOLLOWING PATTERNS USING TRY CATCH BLOCK
a) 1
101
10101
1010101
b) *
0 0
* * *
0 0 0 0
* * * * *
0 0 0 0
* * *
0 0
*
c) 1
1 2 1
1 3 3 1
1 4 6 4 1
15 10 10 5 1
your way of solving problem is much easy. thnkyou
Replysir can u please send code for this pattern please sir!! thak you
Reply1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
sir can u help me in printing this pattern please very urgent its my homework sir!!! thank you sir!!
Reply1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
pls i want to this.....
Reply1
2 7
3 8 12
4 9 13 16
5 10 14 17 19
6 11 15 18 20 21
Hello Chiru N, here is the program for your pattern.
Replypublic class Pattern
{
public static void main(String[] args)
{
int m=6; int r=0;
for (int i= 0;i<m;i++)
{
for (int j=1;j<=1;j++)
{
System.out.print(i+1+" ");
}
int n=0; int u=4;
for (int k=1;k<=r;k++)
{
System.out.print(m+i+n+" ");
n=n+u;
u--;
}
r++;
System.out.println("");
}}
}
Here is the program for your pattern.
Replypublic class Pattern
{
public static void main(String[] args)
{
int m=5; int r=0;
for (int i= 1;i<=m;i++)
{
for (int j=1;j<=1;j++)
{
System.out.print(i+" ");
}
int u=2;
for (int k=1;k<=r;k++)
{
int v=u*i;
System.out.print(v+" ");
++u;
}
r++;
System.out.println("");
}}
}
public class Pattern
Reply{
public static void main(String []args)
{
int n=4; int p=0;
for (int i=1;i<=n;i++)
{
for(int j=1;j<=i+p;j++)
{
if (j%2==0)
{
System.out.print(0);
}
else
{
System.out.print(1);
}
}
p++;
System.out.println("");
}
}
}
public class Pattern
Reply{
public static void main(String []args)
{
int n=4;
for (int i=1; i<=n;i++)
{
for (int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
public class Pattern
Reply{
public static void main(String []args)
{
int n=5;
for (int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if (j%2==0)
{
System.out.print("#");
}
else
{
System.out.print("*");
}
}
System.out.println("");
}
}
}
public class Pattern
Reply{
public static void main(String []args)
{
int n=5;
for(int i=n;i>=1;i--)
{
int m=i;
for (int j=1;j<=(n-i+1);j++)
{
System.out.print(m);
m++;
}
System.out.println("");
}
}
}
public class Pattern
Reply{
public static void main(String []args)
{
int n=5; int m=n;
for(int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
System.out.print(j);
}
System.out.println("");
m--;
}
}
}
hi Smita Tandon here is your code:-
Replyclass Hw1
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
its good but turn it into more easy as easy:
Replyclass Hw3{
public static void main(String args[]){
int i,j;
for(i=5;i>=1;i--){
for(j=1;j<=i;j++){
System.out.print(j);
}
System.out.println();
}
}
}
hi please
ReplyA
BC
DEF
GHIJ
KLMNO
HELP .....JUST NORMAL INT I,J NO LN OR OTHER FNCTIONS PLAESE
Hello harry singh, here is the program for your pattern...!
Replypublic class Pattern
{
public static void main(String[] args)
{
int a=65;
for(int i=1; i<=5;i++)
{
for (int j=1; j<=i;j++)
{
System.out.print((char)a);
a++;
}
System.out.println();
}
}
}
code for
Reply1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
Check this code for
Reply1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
public class Pattern
{
public static void main(String[] args)
{
int p=0;
for (int i=1;i<=4;i++)
{
for (int j=1;j<=i+p;j++)
{
if(j%2==0) {System.out.print("*");}
else {System.out.print(i); }
}
p++;
System.out.println("");
}
int q=3;
for (int i=4;i>=1;i--)
{
for (int j=1;j<=i+q;j++)
{
if(j%2==0) {System.out.print("*");}
else {System.out.print(i); }
}
q--;
System.out.println("");
}
}
}
program for
Reply1
24
135
2468
13579
public class Mysample
{
public static void main (String args[])
{
for(int i=1;i<=5;i++)
{
int m=1; int n=2;
for (int j=1;j<=i;j++)
{
if(i%2!=0) {System.out.print(m); m+=2;}
else {System.out.print(n); n+=2;}
}
System.out.println();
}
}
}
11111
Reply2222
333
44
5
how to print this pattern
----1
Reply---32
--654
-10987
- refers to spaces
----1
Reply---32
--654
-10987
- refers to spaces
----1
Reply---32
--654
-10987
- refers to spaces
----1
Reply---32
--654
-10987
- refers to spaces
program for
Reply11111
2222
333
44
5
public class Pattern
{
public static void main(String[] args)
{
int n=5;
for (int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
System.out.print(i);
}
System.out.println("");
}
}
}
Program for
Reply1
32
654
10987
public class Pattern
{
public static void main(String[] args)
{
int n=4; int m=n; int p=1;
for(int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
System.out.print(" ");
}
int q=p;
for(int k=1;k<=i;k++)
{
System.out.print(q);
q--;
}
System.out.println("");
p=p+i+1;
m--;
}
}
}
The above program is for this pattern,
Reply----1
---32
--654
-10987
11
Reply11 12
11 12 13
11 12 13 14
my progress till far is,according to the logic
class Series {
public static void main( String arg[]){
int n=11;
for(int i=1;i<4;i++){
for(int j=1;j<=i;j++)
System.out.print(+n);
n++;
}
{ System.out.println();}
}
}
help me out
11
Reply11 12
11 12 13
11 12 13 14
my progress till far is,according to the logic
class Series {
public static void main( String arg[]){
int n=11;
for(int i=1;i<4;i++){
for(int j=1;j<=i;j++)
System.out.print(+n);
n++;
}
{ System.out.println();}
}
}
help me out
11
Reply11 12
11 12 13
11 12 13 14
my progress till far is,according to the logic
class Series {
public static void main( String arg[]){
int n=11;
for(int i=1;i<4;i++){
for(int j=1;j<=i;j++)
System.out.print(+n);
n++;
}
{ System.out.println();}
}
}
help me out
1234567
Reply12345
123
1
Please do this program for me.
Reply12345
2345
345
45
5
Program for
Reply11
11 12
11 12 13
11 12 13 14
public class Series {
public static void main( String arg[]){
for(int i=1;i<=4;i++)
{
int n=11;
for(int j=1;j<=i;j++)
{
System.out.print(n+" ");
n++;
}
System.out.println();
}
}
}
Program for
Reply1234567
12345
123
1
public class Pattern {
public static void main( String arg[]){
int n=7;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=n;j++)
{
System.out.print(j);
}
System.out.println();
n=n-2;
}
}
}
Program for
Reply12345
2345
345
45
5
public class Pattern {
public static void main( String arg[]){
int n=7;
for(int i=1;i<=5;i++)
{
int m=i;
for(int j=i;j<=5;j++)
{
System.out.print(m);
m++;
}
System.out.println();
}
}
}
can u temme the code for :
Reply1 2 3 4
10 5
9 8 7 6
can u temme the code for :
Reply1 2 3 4
10 5
9 8 7 6
Program for
Reply1-2-3-4
10----5
9-8-7-6
(Note: "-" is used here instead of "space")
public class Pattern
{
public static void main( String[] args)
{
int m=1; int p=10;
for(int i=1;i<=3;i++)
{
for(int j=1;j<=4;j++)
{
if(i==1)
{ System.out.print(m+" ");
m++;}
else if(i==2)
{
if((j==2)||(j==3))
{
System.out.print(" ");
}
else
{System.out.print(p);
p=p/2;}
}
else
{
System.out.print(m+" ");
m--;
}
}
m=m+2;
System.out.println();
}
}
}
number pattern
Reply7
14 15
28 29 30 31
56 57 58 59 60 61
number pattern
Reply7
14 15
28 29 30 31
56 57 58 59 60 61
Here is the code guys...
Replypackage mypack2;
import java.util.Scanner;
public class Testing{
public static void main( String arg[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int c=n;
int i,j;
int t;
for(i=1;i<=n;i++){
for(j=1;j<=c;j++){
System.out.print(c);
}
System.out.println();
c--;
}
t=c+2;
for(i=1;i<=n-1;i++){
for(j=1;j<=t;j++){
System.out.print(t);
}
System.out.println();
t++;
}
}
}
package mypack2;
Replyimport java.util.Scanner;
public class Testing{
public static void main( String arg[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int c=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(j==n){
System.out.print(" "+ ++c);
}
else{
System.out.print(" "+c);
}
}
System.out.println();
}
}
}
i want the code for blow pattern
Reply7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
Program for
Reply7
14 15
28 29 30 31
56 57 58 59 60 61
public class Pattern {
public static void main( String arg[]){
int n=7; int m=2;
for(int i=1;i<=4;i++)
{
int q=n;
if(i==1) {m=1;}
for(int j=1;j<=m;j++)
{
System.out.print(q+" ");
q++;
}
n=n*2;
if (i==1) {m=m+1;}
else {m=m+2;}
System.out.println();
}
}
}
Program for
Reply7-8-9-10
6-1-2-11
5-4-3-12
16-15-14-13
(Note: here "-" is used instead of "whitspace")
public class Pattern
{
public static void main( String[] args)
{
int n=4; int m=n;
int[][]a=new int[n][m];
int d=1; int e=1;
for(int i=1;i<=(n*n);i++)
{
if((i==2) || (i==8)|| (i==9)|| (i==10)) {++e;}
else if((i==4) || (i==5)|| (i==14)|| (i==15) ||(i==16)) {--e;}
else if((i==3) || (i==11)|| (i==12)|| (i==13)) {++d;}
else if((i==6) || (i==7)){--d;}
a[d][e]=i;
}
for (int j=0;j<n;j++)
{
for(int k=0;k<n;k++)
{
System.out.print(a[j][k]+"\t");
}
System.out.println("");
}
}
}
public class T{
Replypublic static void main(String[] arr)
{
int c=1,i,j,k;
int n,m=3,z=3;
for(i=0;i<5;i++){
n=5;
for(k=1;k<=i;k++){
if(i>=1)
System.out.print(" -");
}
for(j=1;j<=5-i;j++){
System.out.print(" "+n--);
}
System.out.println();
}
for(i=3;i<=6;i++){
n=5;
if(m==0){
break;
}
else
{
for(k=1;k<=m;k++){
System.out.print(" -");
}
}
if(z<1){
break;
}
else
{
for(j=5;j>z;j--){
System.out.print(" "+j);
}
}
m--;
z--;
System.out.println();
}
}
}
hi i want code for
Reply1
3*2
4*5*6
10*9*8*7
11*12*13*14*15
Program for
Reply1
3*2
4*5*6
10*9*8*7
11*12*13*14*15
public class Pattern
{
public static void main( String[] args)
{
int n=5; int p=0; int m=1;
for(int i=1;i<=n;i++)
{
for (int j=1;j<=(i+p);j++ )
{
if(j%2!=0)
{
System.out.print(m);
if(i%2==0){m--;}
else{++m;}
}
else
{
System.out.print("*");
}
}
if((i==1)){m=m+1;}
if((i==2)||(i==3)){m=m+3;}
else if(i==4){m=m+5;}
System.out.println();
p++;
}
}
}
In the above code neglect int n=7; (it is unused variable)
Reply54321
Reply4321
321
21
1
Please solve
Sir I want a java program which should display the following output
Replyinput:4
output:
4
8 20 32 44
12 24 36 48
16 28 40 52
Program for
Reply54321
4321
321
21
1
public class Pattern
{
public static void main( String[] args)
{
int n=5; int k=n;
for(int i=1;i<=n;i++)
{
int m=k;
for (int j=i;j<=n;j++)
{
System.out.print(m);
m--;
}
System.out.println("");
k--;
}
}
}
4
Reply8 20 32 44
12 24 36 48
16 28 40 52 that code is given below......
class ForthMultiplication
{
p.s.v.m(Strings a[])
{
int a=2,b=2,n=4;
s.o.pln(n);
for(int i=1;i<=3;i++)
{
for(int j=1;j<=4;j++)
{
s.o.p(n*a+" ");
a+=3;
}
b++;
a=b;
s.o.pln();
}
}
}
Program for
Replyinput:4
output:
4
8 20 32 44
12 24 36 48
16 28 40 52
public class Pattern
{
public static void main( String[] args)
{
int n=4;
// instead of entering n value here, you can get input from user using scanner.
int m;
for(int i=1;i<=n;i++)
{
if (i==1) {m=n/n;}else{m=n;}
int k=n*i;
for(int j=1;j<=m;j++)
{
System.out.print(k+" ");
k=k+((n-1)*n);
}
System.out.println("");
}
}
}
sir
ReplyThanks for solve my problem
But i don't get proper output as per my pettern.
As per your code New Output is :
4
8
20
32
44
12
24
36
48
16
28
40
52
sir please help in solving this:
Replywrite a class that stores and prints numbers given to it.the numbers are given to this class by calling store method. this method accepts one number at a time. the numbers are printed by calling the print method. numbers should be printed in order they were given to the class
public class comment {
Replypublic static void main( String args[])
{
for(int i=5,r=1;i>0;i--,r++)
{
for(int j=r;j<=5;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
public class comment {
Replypublic static void main( String args[])
{
for(int i=5,r=1;i>0;i--,r++)
{
for(int j=r;j<=5;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
please help in making the pattern shown below
Reply1
_2
__3
___4
____5
Program for
Reply1
_2
__3
___4
____5
public class Pattern
{
public static void main(String[] args)
{
int n=5;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if (i==j)
{
System.out.print(i);
}
else
{
System.out.print(" ");
}
}
System.out.println("");
}
}
}
Show me the pattern for this please:
Reply01 02 07 08 13 14 19 20 25 26
03 04 09 10 15 16 21 22 27 28
05 06 11 12 17 18 23 24 30 31
1
Reply2 3
4 5 6
7 8 9 10
11 12 13 14 15
Please help how do you do this
Reply1 = 1
1 + 2 = 3
1 + 2 + 3 = 6
1 + 2 + 3 + 4 = 10
1 + 2 + 3 + 4 + 5 = 15
1 + 2 + 3 + 4 + 5 + 6 = 21
1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
Hello,
ReplyHow to Print
1*2*3
7*8*9
4*5*6
where n=3
Program for
Reply1*2*3
7*8*9
4*5*6
class Pattern
{
public static void main(String []args)
{
int n=3;
int m=1; int p=(n*2)+1;
for(int i=1;i<=n;i++)
{
if(i!=2){
for(int j=1;j<(n*2);j++)
{
if(j%2!=0)
{System.out.print(m);
m++;}
else
{
System.out.print("*");
}
}}
else
{
for(int j=1;j<(n*2);j++)
{
if(j%2!=0)
{System.out.print(p);
p++;}
else
{
System.out.print("*");
}
}
}
System.out.println("");
}
}
}
Program for
Reply1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
class Pattern
{
public static void main(String []args)
{
int n=5;
int m=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(m+" ");
m++;
}
System.out.println("");
}
}
}
Please help me create a code that will display exactly this:
Reply1 = 1
1 + 2 = 3
1 + 2 + 3 = 6
1 + 2 + 3 + 4 = 10
1 + 2 + 3 + 4 + 5 = 15
1 + 2 + 3 + 4 + 5 + 6 = 21
1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
Make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.