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 201 – 400 of 1223 Newer› Newest»hello sir i want a code to print 3rd math table.........the result must be odd numbers in the table that means only odd numbered result have to print,should be in line by line format.........thank you.
ReplyHello, below code can help you
Replyclass Pattern3 {
public static void main(String[] args){
int i,j,k=1;
for(i=5;i>=1;i--){
for(j=k;j<=5;j++){
System.out.print(j);
}
k++;
System.out.println();
}
}
}
SOOOS
ReplyOSOSO
OOSOO
OSOSO
SOOOS
can any one help me out this pattern.........
i want to learn java...these are my basic questions...
ReplyQ1 : Check whether number is prime or not if prime then print all prime number upto 50 and generate sum .
Q 2 : Write a program to find the product of the sums of all odd & even digits in a given number ?
Q 3 : Write a program to find the number & sum of all Integers 100>no.>200 that is divisible by 7 ?
Q 4 : Write a program in java to find the largest of 3 numbers by using conditional operator ?
Q 5: Write a program in java to sort the elements of an array in ascending order by using bubble sort ?
Q 6 : Write a program in java to implement matrix multiplication ?
Q 7 : Check number is even or not if even then print list in reverse order [range 1 -60]
Q 8 : Write a program in java to display the first 10 numberof Fibonacci series and find factorial of the last number of the produced Fibonacci series.
Q 9 : Write a simple program to implement constructor ?
what is the coding for this patterns
Reply1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
&
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
can you help me for this pattern
Reply1
0 0
1 1
0 0
1
public class Third {
Replypublic static void main(String[] args) {
int y=1;
int m=1;
for(int i=1;i<=5;i++){
if(i==1 || i==5){
System.out.print(m);
}
else{
if(i%2==0){
y=0;
}
else{
y=1;
}
for(int k=1;k<=2;k++){
System.out.print(y+" ");
}
}
System.out.println();
}
}
}
public class Third {
Replypublic static void main(String[] args) {
int j=1;
for(int i=1;i<=5;i++){
for(int k=1; k<=i; k++){
System.out.print(j+" ");
j++;
}
System.out.println();
}
}
}
Thanks Anand prakas yadav for solving everyone's problem. We really appreciate this!
Replypublic class Third {
Replypublic static void main(String[] args) {
for(int i=1;i<=9;i++){
int u=i-1;
for(int j=1;j<=i;j++){
System.out.print(j);
}
for(int k=1;k<=i-1;k++){
System.out.print(u);
u--;
}
System.out.println();
}
}
output is-------
Reply1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
sir we solve the following pattern in how many ways :
Reply------1
-----121
---12321
-1234321
---12321
-----121
-------1
Reply soon SiR. thank U :)
package abc;
Replypublic class Six {
public static void main(String[] args) {
// TODO Auto-generated method stub
int v=4;
int r=2;
for(int i=1;i<=4;i++){
for(int l=1;l<=v;l++){
System.out.print("-");
}
int u=i-1;
for(int j=1;j<=i;j++){
System.out.print(j);
}
for(int k=1;k<=i-1;k++){
System.out.print(u);
u--;
}
v=v-1;
System.out.println();
}
for(int t=1;t<=3;t++){
for(int y=1;y<=r;y++){
System.out.print("-");
}
int u=3-t;
for(int j=1;j<=4-t;j++){
System.out.print(j);
}
for(int k=1;k<=3-t;k++){
System.out.print(u);
u--;
}
r=r+1;
System.out.println();
}
}
}
you can solve this pattern in many ways like as using while or other methods.Because you can solve any problem in many ways.
thank U sir . u got programming powers :D
Replycan u pls help me get coding for my programs
Replyfor this pattern...
Reply0
0 2
0 2 4
0 2 4 6
0 2 4 6 8
1 5 10 10 5 1
Reply1 4 6 4 1
1 3 3 1
1 2 1
1 1
1
can you solve this ??
Please help me asap
Reply11111
22221
33321
44321
54321
public class Example {
Replypublic static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=1; i<=5;i++){
int s=i;
for(int g=1;g<=6-i;g++){
System.out.print(i);
}
for(int h=1;h<=i-1;h++){
System.out.print(s-1);
s--;
}
System.out.println();
}
}
}
public class Example {
Replypublic static void main(String[] args) {
// TODO Auto-generated method stub
int e=0;
for(int i=1; i<=5;i++){
for(int g=1;g<=i;g++){
System.out.print(e+" ");
e+=2;
}
e=0;
System.out.println();
}
}
}
*
Reply* *
* * *
* * * *
* * * * * *
* * * *
* * *
* *
*
this 1 sir whats the code
1
Reply3 5
7 9 11
13 15 17 19
send me program for this pattern
send me program sir.......
Replysir plzzzzzz help
Reply1
1 2 1`
1 2 3 2 1
1 2 3 4 3 2 1
public class Example4 {
Replypublic static void main(String[] args) {
// TODO Auto-generated method stub
int g=1;
for(int i=1; i<=4;i++){
for(int j=1; j<=i;j++){
System.out.print(g+" ");
g+=2;
}
System.out.println();
}
}
}
public class Pattern {
Replypublic static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=1;i<=5;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
if(j==5){
System.out.print("*");
}
}
System.out.println();
}
for(int h=1;h<=4;h++){
for(int t=4;t>=h;t--){
System.out.print("*");
}
System.out.println();
}
}
}
public class Man {
Replypublic static void main(String[] args) {
for(int i=1;i<=4;i++){
int u=i-1;
for(int j=1;j<=i;j++){
System.out.print(j+" ");
}
for(int k=1;k<=i-1;k++){
System.out.print(u+" ");
u--;
}
System.out.println();
}
}
}
hello can you help me printing this
Reply***
**
*
sir plz help me for this pattern
Reply15 14 13 12 11
10 9 8 7
6 5 4
3 2
1
class Pattern
Reply{
public static void main(String args[])
{
int n=3;
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
finally i done.
Reply------------------------------------------------------------------------------------
class NumPattern
{
public static void main(String args[])
{
int ln=5;
int x=15;
for(int i=1;i<=5;i++)
{
for(int j=ln;j>=i;j--)
{
System.out.print(x+" ");
x--;
}
System.out.println();
}
}
}
Sir please give me a java code for the pattern
Reply..........1
.......1 2 1
....1 2 3 2 1
Sir please..................its very urgent
ReplyPlease check comment <30/> above, same program solved there!
ReplyHello Akshay!
ReplyPlease check comment no. <39/> or <96/> above.... same question solved there!
Looks like you didn't check the above comments I mentioned :)
ReplyOk, so you can grab your code with correct spacing you want below:
class Main1 {
public static void main(String Args[]) {
int max = 4; //max no. in series
//Upper Triangle
for(int i=1;i<=max;i++){
for(int s=0;s<max-i;s++){
System.out.print(" "); //Spacing
}
for(int j=1;j<=i;j++){
System.out.print(j); //ascending print
}
for(int k=i-1;k>=1;k--){
System.out.print(k); //descending print
}
System.out.println(); //new line
}
//Lower Triangle
for(int i=1;i<=max-1;i++){
for(int s=max-i;s<max;s++){
System.out.print(" "); //Spacing
}
for(int j=1;j<=max-i;j++){
System.out.print(j); //ascending print
}
for(int k=max-i-1;k>=1;k--){
System.out.print(k); //descending print
}
System.out.println(); //new line
}
} //end of main
}
Hope that's what you looking for!
Hi sir your website is very helpful , thanks sir
ReplyCan I get the code for these pattern s
123454321
1234 4321
123 321
12 21
1 1
And
1
121
12321
1234321
Hello!
ReplyKindly scroll to top and check comment no. 11 and 41 for both of your questions solution respectively....
1 6 10 13 15
Reply2 7 11 14
3 8 12
4 9
5
class Main1 {
public static void main(String Args[]) {
int rows=5 , i , j , k , print;
for( i=1; i<=rows; i++ ){
for( j=rows-i,k=0,print=i; j>=0; j--,k++ ){
System.out.print(print+" ");
print+=rows-k;
}
System.out.println();
}
}
}
pls sir print the this name=sagar
Replyin the start pattern
pls sir print the this name=sagar
Replyin the start pattern
Sir can we right the last for loop like this?
Replyfor (int j=0; j <i; j++, cout++)
Yes Prajwal we can write like this as well
Replysir please help me with this java program
Reply-------*
------*1*
----*121*
---*12321*
--***********
Your prog:
Replypublic class pattern8
{
public static void main(String args[])
{
int i,j,k,c=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
System.out.print(j);
System.out.print(" ");
for(k=c;k>=1;k--)
System.out.print(k);
System.out.println();
c++;
}
}
}
Regs
public class pattern8
Reply{
public static void main(String args[])
{
int i,j,k,c=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
System.out.print(j);
System.out.print(" ");
for(k=c;k>=1;k--)
System.out.print(k);
System.out.println();
c++;
}
}
}
SIR CAN YOU GIVE ME CODE FOR THE FOLLOWING CODE:
ReplyA
AB
ABC
ABCD
ABCDE
Sir,
ReplyI need help in this program :
123456789
2345678
34567
456
5
456
34567
2345678
123456789
hello world
ReplyBetter program for pattern 4 without using another r variable.
Replypackage patterns;
public class Bow_number_pattern {
public static void main(String[] args) {
/* 1
* 1 2
* 1 2 3
* 1 2 3 4
* 1 2 3 4 5
* 1 2 3 4
* 1 2 3
* 1 2
* 1
*/
int i,j;
int increase_loop_count=0,decrease_loop_count=1;
while(decrease_loop_count>=1)
{
if(increase_loop_count==0)
{
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
System.out.print(j+" ");
System.out.println();
}
increase_loop_count++;
}
else
{
for(i=1;i<=5-1;i++)
{
for(j=1;j<=5-i;j++)
System.out.print(j+" ");
System.out.println();
}
decrease_loop_count--;
}
}
}
}
write code for
Reply2
4 6
8
hello sir, could u plz help me out in getting this pattern?
Reply1
01
101
0101
10101
what will be the code for this pattern?
Reply1A 3B 5A
1B 3A 5B
2A 4B 6A
2B 4A 6B
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++)
{
System.out.print(j);
}
if(i==n)
{
System.out.print("");
}
else
System.out.print(" ");
for(int k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}
A B C D E D C B A
ReplyA B C D D C B A
A B C C B A
A B B A
A A
pls help me out find the code fr dis program
pls sir can u help me solve dis program plzzzzz!!!!
Reply1. 123456789
2345678
34567
456
5
456
34567
2345678
123456789
Sir.. Plz help me to solve this..
Reply___2_________4____
_2_4_2_____3_4_3_
2_4_6_4_2_3_4_3_2
_1_3_1_____3_4_3__
___1_________4_____
Plz.. Reply as soon as possible.. (__ its space.. Hope u can understand)
SIR
ReplyCould you tell me the code for this following pattern
1
333
55555
7777777
55555
333
1
Pl help me with this Patten
Reply------------1
---------1 2
------1 2 3
---1 2 3 4
1 2 3 4 5
- spaces can be anything but alignment should be maintained as shown pl help me
class PatternShape
Reply{
public static void main(String[] ar)
{
int n=5;
for(int i=1;i<=5;i++)
{
for(int s=1;s<=n-i;s++)
{
System.out.print("-");
}
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
class PatternsDemo
Reply{
public static void main(String[] ar)
{
int n=7;
for(int i=1;i<=n;i+=2)
{
System.out.println("");
for(int j=1;j<=i;j++)
{
System.out.print(i);
}
}
for(int i=n-2;i>0;i-=2)
{
System.out.println("");
for(int j=i;j>0;j--)
{
System.out.print(i);
}
}
}
}
class PatternDemo
Reply{
public static void main(String[] ar)
{
int n=5;
for(int i=0;i<5;i++)
{
System.out.println("");
for(int j=i+1;j<=9-i;j++)
{
System.out.print(j);
}
}
for(int i=n-1;i>0;i--)
{
System.out.println("");
for(int j=i;j<=9-(i-1);j++)
{
System.out.print(j);
}
}
}
}
class PatternDemo
Reply{
public static void main(String[] ar)
{
int n=5;
for(int i=0;i<5;i++)
{
System.out.println("");
for(int j=i+1;j<=9-i;j++)
{
System.out.print(j);
}
}
for(int i=n-1;i>0;i--)
{
System.out.println("");
for(int j=i;j<=9-(i-1);j++)
{
System.out.print(j);
}
}
}
}
class CodeDemo
Reply{
public static void main(String[] ar)
{
int n=5;
for(int i=1;i<=n;i++)
{
System.out.println("");
for(int j=1;j<=i;j++)
{
if(i==1)
{
System.out.print("1");
}
else
{
if(i%2==0)
{
if(j%2==0)
System.out.print("1");
else
System.out.print("0");
}
else
{
if(j%2==0)
System.out.print("0");
else
System.out.print("1");
}
}
}
}
}
}
pls tell me the code
Reply1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
pls sir help me to get the code for
Reply1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
prg to print prime numbers from 1 to 100
Replyclass Jamer
Reply{
public static void main(String...s)
{
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.print("\n");
}
}
}
class PrimeNumbers
Reply{
public static void main(String[] ar)
{
int i,j;
for(i=1;i<=100;i++)
{
int count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2)
{
System.out.print(i+"\t");
}
}
}
}
123456789
Reply2345678
34567
456
5
456
34567
2345678
123456789
Hi sir,
ReplyHow do you print the following pattern:
1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 1
1 2 3 3 3 3 3 2 1
1 2 3 4 4 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 4 4 3 2 1
1 2 3 3 3 3 3 2 1
1 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 1
Please tell me the java program for the pattern
Reply1
121
12321
1234321
12321
121
1
Greetings sir....cud u plz solve these patterns...
Reply1) 1 2 3 4 5
6 7 8 9
10 11 12
13 14
15
2) 15 14 13 12 11
10 9 8 7
6 5 4
3 2
1
3) 1 3 5 7 9
3 5 7 9 1
5 7 9 1 3
7 9 1 3 5
9 1 3 5 7
ASAP will be deeply appreciated...thnx n advance.....
Hi,
Replyplease help me to print this pattern
1 6
2 7
3 8
4 9
5 10
1
Reply2 2 2
3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5
5 4 3 2 1
Reply4 3 2 1
3 2 1
2 1
1
PLEASE TELL ME HOW TO PRINT
Reply3 33 333 3333 33333
3 33 333 3333 33333
3 33 333 3333 33333
3 33 333 3333 33333
3 33 333 3333 33333
1
Reply1 A
1 A 1
1 A 1 B
1 A 1 B 1
import java.io.*;
Replyclass Pat
{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void main() throws IOException
{ System.out.println("Input a string:");
String str=br.readLine();
System.out.println();
int len=str.length();
for(int i=0; i<len; i++)
{ char ch=str.charAt(i);
for(int j=1; j<i+2;j++)
{
System.out.print(ch);
}
System.out.println();
}
}
}
what is code for
Reply11111
12221
13331
14441
11111
sir plz give me the code of this pattern
ReplyJ
J A
J A V
J A V A
J A V A 2
J A V A 2 J
J A V A 2 J E
J A V A 2 J E E
J A V A 2 J E E 3
how to print when n is given =2
Reply112
322
please provide code for following pattern
Reply*
**
***
****
*****
sorry , following is the pattern i actually wanted to know:
Reply----*
---**
--***
-****
*****
sir it is not pattern program but can you pls solve these 3 programs
Reply1) to print the roman equivalent of the number which is entered(without using the method directly)
2) to enter a word and print a character only once if it is repeated in the word for ex. if i enter aabbccdd then the output should be abcd.
3) to enter an integer and give the result as the sum of its digits raise to the power of there position.
for ex. if i enter 491 then the output should be 4 to the power 1 + 9 to the power 2 + 1 to the power 3.
pls help sir
sir please solve this
Reply1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
how to print
Reply1
23
456
78910
1112131415
I want a java program which should display the following output
ReplyH
HE
HEL
HELL
HELLO
HELL
HEL
HE
H
****1
Reply***2*
**3**
*4***
5****
*6***
**7**
***8*
****9
with stars!
can i get the correct code for this pattern
can u help me in printing the following pattern upto a given limit...
Replyfor example if iam giving the limit as 12 my output should be
0
0 2
2 4 6
6 8 10 12
can u help me to print the pattern
Reply0
0 2
2 4 6
6 8 10 12
can you please help me to print the following
Reply1 2 3 4 5
2 4
3 3
4 2
5 4 3 2 1
Help me in doing this pattern using loops only:
Reply* * * * * *
*
*
*
*
* * * * *
class Main1 {
public static void main(String[] args){
int n = 6;
for(int i=0;i<n;i++){
if(i==0 || i==n-1){
for(int j=0;j<n;j++){
System.out.print("*");
}
} else{
System.out.print("*");
}
System.out.println();
}
}
}
123456787654321
Reply1234567_7654321
123456___654321
12345_____54321
1234_______4321
123_________321
12___________21
1_____________1
Please help me... Thank you..
Reply123454321
1234_4321
123___321
12_____21
1_______1
please solve the pattern
ReplySample output for 3 rows
1 3 5
* 2 *
1 3 5
Hey, Please solve the pattern
Reply(Ques-1)
A
AB
ABC
ABCD
ABCDE
(Ques - 2)
H
HE
HEL
HELL
HELLO
HELL
HEL
HE
H
please help me sir
ReplyProblem Statement: x pattern using 1 and o s center
Generate the following pattern for an input say 1110111 where equal number of 1's can be prefixed and suffixed where 0 must be at the middle position and the total number of digits must be odd.
1 1
1 1
1 1
0
1 1
1 1
1 1
Dos and Donts
Minimum no. of digits should be 3, say 101.
Maximum no. of digits should be 19.
Input should be read as long data type.
(Don't read the input as String type)
please help me sir , this is too complicated
S
ReplyS U
S U S
S U S H
S U S H I
SIR, pls help me to solve this program
Hello Sir,
ReplyCan you please help me with following pattern-
0 1 1 1 1
1 2 2 2 2
3 4 4 4 4
5 6 6 6 6
7 8 8 8 8
Check comment no. 27 and 64 for source code!
Reply# # # # # # #
Reply#
#
#
#
#
# # # # # # #
Any one can help me to do this ? :)
can you help me
Reply1
12
123
123
12
1
1
Reply2 6
3 7 10
4 8 11 13
5 9 12 14 15
write a program to print above triangle
int rows=5 , i , j , k , print;
Replyfor( i=1; i<=rows; i++ )
{
for( j=i,k=1,print=i; j>0; j--,k++ )
{
System.out.print(print+" ");
print+=rows-k;
}
System.out.println();
}
what will be the code for
Reply@ # #
@ @ #
@ @ @
what will be the code for
Reply@ # #
@ @ #
@ @ @
a
Replyab
abc
abcd
and so on upto specified number of letters. How do you do it?
just a correction..
Replyi would like to have the solution program only with two variables(eg..i and j).
thank you
sir i have another also:-
Reply1 1
12 21
123 321
1234 4321
1234554321
Check comment no. 1 and 11 for solution of this pattern.
Reply12345
Reply1234
123
12
1
1
Reply12
123
1234
12345
can you give java source code for the following as fast as possible(very urgent):-
Reply(i)
1
121
12321
1234321
12321
121
1
pls help me with this pattern prog
Reply1
13
135
1357
13579
how to print the sum of series..?
Reply1. s=a+a^2/2!+a^3/3!+................a^n/n!
2. s=x/3+x/8+x/15......n
plz reply asap
Please help to solve this problems
Reply1
3 2
6 5 4
10 9 8 7
4
2 5 7
1 3 6 8 9
public class Patterns1{
Replypublic void main(int n){
for(int i=1;i<=(2*n-1);i++){
if(i<=n)
print(i);
else
print(2*n-i);
System.out.println();
}
}
public void print(int x){
for(int i=1;i<=(2*x-1);i++)
if(i<=x)
System.out.print(i+" ");
else
System.out.print((2*x-i)+" ");
}
}
could some one please help me with this.. I really appreciate it...
Reply- - 4
- 2 5 7
1 3 6 8 9
could u send the code for below pattern
Reply*
* *
* *
* *
*
1
Reply1 2 1
1 2 4 5 1
1 3 5 9 14 15 1
need this pattern..
Thanks
1
Reply2 3 4
5 6 7 8 9
10 11 12 13 14 15 16
sir, please give the code for this
Dear sir
Replyplease help me
how to print W format out put
* *
* * *
* * * *
* *
I want code for following pattern
Replyfor n=4
1111
1001
1001
1111
n=5
11111
10001
10101
10001
11111
*
Reply* *
* *
* *
*
Reply* *
* *
* *
What about this code:
Reply1***
12**
123*
public static void main(String[] args) {
Reply// TODO Auto-generated method stub
int n = 5;
for (int i = 1; i <= n; 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.print("\n");
}
}
import java.util.*;
Replyimport java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class pattern
{
public static void main(String args[])throws IOException
{
int n=5;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
for(int k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}
import java.util.*;
Replyimport java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class pattern
{
public static void main(String args[])throws IOException
{
int n=5;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
for(int k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}
sir I want to know how do u tackle any pattern programs.I want to learn n understand ur logical thinking process ability. plz plz do rply.
ReplyCan you please solve this by today? Its for my computer exam tomorrow...thanks in advance
Reply123454321
1234 4321
123 321
12 21
1 1
Scroll up and search for comment <11/> or just search your pattern in 'search box' you will find my previous solution for the same pattern.
ReplyBest of luck for your exam :)
Try to create 5 to 10 patterns manually with/without taking any hint you will get the logic what's same in every pattern.....
ReplyI suggest you to practice regularly for 3-4 days and try to understand how the numbers (to be printed) are generated and how next value is related to previous values!
public class pyanum
Reply{
public static void main ( String [] args )
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=i;j<=5;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
i want this pattern code plz help me sir
Reply111112
311112
311114
511114
511116
and so on
Sir i want an output as follows:
ReplyEnter a string in between A to Z (only odd characters like A or C or E )
ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
A A
Sir i want an output as follows:
ReplyEnter a string in between A to Z (only odd characters like A or C or E )
ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
A A
public static void main(String args[])
Reply{
int i,j,k;
for(i=4;i>=1;i--)
{
for(j=1;j<4;j++)
{
if(j<=i)
System.out.print(j);
else
System.out.print(" ");
}
for(j=4;j>=1;j--)
{
if(j<=i)
System.out.print(j);
else
System.out.print(" ");
}
System.out.println();
}
}
}
HI gil,
Replyhere program for above pattern
public static void main(String args[])
{
int i,j,k;
for(i=4;i>=1;i--)
{
for(j=1;j<4;j++)
{
if(j<=i)
System.out.print(j);
else
System.out.print(" ");
}
for(j=4;j>=1;j--)
{
if(j<=i)
System.out.print(j);
else
System.out.print(" ");
}
System.out.println();
}
}
}
OUTPUT SHOULD BE DISPLAYED AS FOLLOWS:
Reply> Enter an odd character in between A and Z
> User will enter "E"nce the user enter E. the output displayed should be as followed
ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
A A
11
Reply21 22
31 32 33
41 42 43 44
51 52 53 54 55
11
Reply21 22
31 32 33
41 42 43 44
51 52 53 54 55
11
Reply21 22
31 32 33
41 42 43 44
51 52 53 54 55
11
Reply21 22
31 32 33
41 42 43 44
51 52 53 54 55
please solve this one:
Reply*
***
****
***
*
1
Reply2 4
3 5 7
6 8 10 12
1
Reply2 1
3 2 1
4 3 2 1
i want logic for this patter please help me out
how to print this pattern
Reply12345
2345
345
45
5
program for this pattern
Reply12345
2345
345
45
5
1 2 3 4 5 6
Reply1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
code please
1
Reply2 3
3 4 5
4 5 6 7
5 6 7 8 9
give me code for this
Check This Code
Replypublic class pattern
{
public static void main(String []args)
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
System.out.print(j%2);
}
System.out.println();
}
}
}
Please solve
ReplyWrite a java program that asks user a character ch and a integer n and print a S pattern using n lines
output:
ch=@
n=6
@@@@@@
@
@@@@@@
@
@@@@@@
///0///
Reply//010//
/01210/
//010//
///0///
Note : / represents space.
1
Reply00
11 1
0000
…..
please help me.....
Hello, i want a java code for the below pattern
Reply1
2 6
3 7 10
4 8 11 13
5 9 12 14
Sir please can you help me with the code for
Reply1
1+2=3
1+2+3=6
Till
1+2+3+4+5+6+7+8+9+10=55
Your help is always appreciate, please make it asap, thank you.
import java.util.*;
Replypublic class pattern
{
public static void main(String args[])
{
int n,i,j;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the size of the pattern");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==0)
System.out.print("0");
else
System.out.print("1");
}
System.out.println();
}
}
}
check this code for
1
00
111
0000
Check this code Divya.
Replypublic class pattern7
{
public static void main(String args[])
{
int i,j;
for(i=6;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for(i=2;i<=6;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Hello Vasavi !!!!
ReplyTry this code
public class pattern9
{
public static void main(String args[])
{
int i,j;
for(i=0;i<=4;i++)
{
for(j=i;j>=1;j--)
{
System.out.print(j);
}
System.out.println();
}
}
}
Class abc {
ReplyVoid display{
Int p =3 ;
For(int x=0; x<=2;x++){
For(int y=1;y<=p;y++){
System.out.print(" ");}
For(int z=0;z<=x;z++){
System.out.print(z);}
For(int i =2;i<=3-x;i--){
System.out.print(x-1);}
p=p-1;
System.out.println(" ");}
Int s= 2;
For(int n=1;n<=0;n--){
For(int m=1;m<=s;m++){
System.out.print(" ");}
For( int o =0;o<=n;o++){
System.out.print(o);}
For(int w = 2;w>=n;w--){
System.out.print(n-1);}
S++;
System.out.println(" ");}
}
}
Wrong
Replypublic class pattern11 {
Replypublic static void main(String args[])
{
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();
}
5
Reply545
54345
5432345
543212345
Sir ? How to code this
Reply1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Sir ? How to code this
Reply1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Write a method called printNumbers that accepts a maximum number as a parameter and prints each number from 1 up to that maximum, inclusive, boxed by square brackets. For example, consider the following calls:
ReplyprintNumbers(15);
printNumbers(5);
These calls should produce the following output:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]
[1] [2] [3] [4] [5]
123454321
Reply1234 4321
123 321
12 12
1 1
How to do this pattern? Please rply as soon as possible:
Reply1234321
123 321
12 21
1 1
12 21
123 321
1234321
Where are these pattern problems used when tackling real life programming situations, like while developing certain kind of application?
ReplyCan u help with me this???
Reply123456789
--12345678
----1234567
------123456
--------12345
----------1234
------------123
--------------12
Hello! ma-wabeauty, here's the code you want:
Replypublic class Pattern {
public static void main( String args[]){
for(int i=1 ; i<=8 ; i++){
for(int k=9-i ; k<8 ; k++){
System.out.print(" ");
}
for(int j=1 ; j<=10-i ; j++){
System.out.print(j);
}
System.out.println();
}
}
}
i have not understood
Replyhi
Replyif u could explain me use of int test,j,i in the prg
SIR PLEASE SOLVE THIS PROGRAM
Replywrite a program to generate afollowing pattern :
$
???
<<<<<
<<<<<<<
#########
Under recursive structure, a sum of a number X is equal to X+(X-1)+(X-2)+...+1.
ReplyCreate a class called recursiveSum which will compute and print the sum of an integer on the screen
public class Pattern25
Reply{
public static void main(String[] args)
{
int left = 1, right = 1;
for(int i = 1; i <=5; i++)
{
for(int k = 1; k <= left; k++)
{
System.out.print(k);
}
System.out.print(" ");
for(int k = right; k >= 1; k--)
{
System.out.print(k);
}
right++;
left++;
System.out.println();
}
}
}
import java.util.Scanner;
Replypublic class Pattern28
{
public static void main(String[] args)
{
System.out.println("Enter the number of rows in Pattern");
Scanner scn = new Scanner(System.in);
int row_num = scn.nextInt();
for(int i = 1; i <= row_num; i++)
{
if((i % 2) != 0)
{
for(int j = 1; j <= 5; j++)
{
System.out.print(i);
}
System.out.print(i+1);
}
else
{
System.out.print(i+1);
for(int j = 1; j <= 5; j++)
{
System.out.print(i);
}
}
System.out.println();
}
}
}
import java.util.Scanner;
Replypublic class Pattern29
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows of pattern you want : ");
int row_num = sc.nextInt();
int patt_num = 1;
int inc = 3;
int first_inc = 1;
int second_inc = 0;
for(int i = 1; i <= row_num; i++)
{
if(i == patt_num)
{
for(int j = 1; j <= first_inc; j++)
{
System.out.print(j);
}
patt_num = patt_num + inc;
inc++;
first_inc = first_inc + 2;
second_inc = second_inc + 2;
}
else
{
for(int j = 1; j <= second_inc; j++)
{
System.out.print(j);
}
}
System.out.println();
}
}
}
can u pls help me solve these 2 programs using only 2 for loops....
Reply1) 3
2 3 4
1 2 3 4 5
AND
2) 1 2 3 4 5
2 3 4
3
public class Pattern32
Reply{
public static void main(String[] args)
{
int start = 1,end = 3;
for(int i = 1; i <= 3; i++)
{
for(int j = start; j <= end; j++)
{
System.out.print(j);
}
start = start + 3;
end = end + 3;
System.out.println();
}
}
}
public class Pattern33
Reply{
public static void main(String[] args)
{
int end = 5;
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j <= end; j++)
{
System.out.print(j);
}
System.out.print(" ");
for(int j = end; j >= 1; j--)
{
System.out.print(j);
}
end--;
System.out.println();
}
}
}
What will be the programme for this pattern:
Reply_____1
____21
___321
__4321
_54321
-----*
Reply---* * *
-* * * * *
pls
select any three numbers between 0-9 and to find the probability pattern of that three numbers
Replyfor example:
if i selected as 123 then output will be as:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
how to print given string in w format
Replyp g m
r a
o r
Pls solve this pattern
Reply2
4 6
8 10 12
14 16 18 20
can anyone help me for this pattern
Reply12345
23456
34567
45678
56789
What will be the code for this pattern
Reply1
121
12321
1234321
try it....
Replyclass fun
{
public static void main(String args[])
{
int a=0;
for(int i=1; i<=5; i++)
{
for(int j=5; j>a; j--)
{
System.out.print("_");
}
for(int k=i; k>0; k--)
{
System.out.print(k);
}
System.out.println();
a++;
}
}
}
Make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.