Creating Number Patterns In Java

Creating Number Patterns In Java

Number Pattern in Java
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 :

Pattern 1. 
Pattern 1
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=1;j<=i;j++){
                System.out.print(j);
            }
            System.out.println();
        }
    }
}

Pattern 2. 
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. 
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. 
Pattern 4
To Print this pattern use the following code:
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. 

Pattern 5
To Print this pattern use the following code:
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   401 – 600 of 1223   Newer›   Newest»

try it....

class 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++;
}
}
}



Reply

how to print below pattern for any random number..
01 02 03 04 05
16 17 18 19 06
15 24 25 20 07
14 23 22 21 08
13 12 11 10 09

Reply
This comment has been removed by the author.
This comment has been removed by the author.
This comment has been removed by the author.

Help me print the following pattern depending on the input please :-
input=1
0
input=2
0
00
input=3
0
0
000
----0
----0
input=4
0
0
0
0000
------0
------0
------0000
and so on..
("---" are supposed to be blank, but blank spaces were not counted in the question here so i used those)
so basically its a step pattern where it ends with a vertical line if the number is odd and horizontal line if its even number.

Reply

Please help me to solve the below problem :
input:
n=4,k=2

1,1,1,1
1,1,1,2
1,1,2
1,2,1
2,2

Reply
This comment has been removed by the author.

code for :
1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13

Reply

please send me the java programming code for following pattern
1
222
33333
4444444

Reply

please send me the java programming code for following pattern
1
222
33333
4444444

Reply

class AddSubEx
{
public static void main(String args[])
{
int sum=0;
for(int i=1; i<=10; i++)
{
if(i%2==0)
{
if(i==10)
System.out.print(i+" = ");
else
System.out.print(i+"+");
sum=sum-i;
}
else
{
System.out.print(i+"-");
sum=sum+i;
}
}
System.out.println(sum);
}

}

Reply

Can you tell me code for this pattern
1
23
456
7890

Reply

i want like this
11 12 13
21 22 23
31 32 33
with nested loop

Reply

can i get program for this 1 1
12 21
123 321
1234 4321
123454321

Reply

Hi.
1
11
21
1211
111221
=>Here in every line we are talking about the pervious line elements
like----- in line 2=.> one time 1
in line 3= > two times 1
in line 4=> one time 2, one time 1
in line 5 = > one time 1, one time 2, two times 1
in line 6 = > three times 1, two times 2, one time 1

Reply

Hi.
1
11
21
1211
111221
=>Here in every line we are talking about the pervious line elements
like----- in line 2=.> one time 1
in line 3= > two times 1
in line 4=> one time 2, one time 1
in line 5 = > one time 1, one time 2, two times 1
in line 6 = > three times 1, two times 2, one time 1

Reply
This comment has been removed by the author.

can i get the code for following pattern?


*
**
***
****
*****
****
***
**
*

Reply

can i get the code for
*
_**
__***
___****
____*****
___****
__***
_**
*

Reply

how to print a dynamic arrow with filled "*"?

Reply

plz sove this to print
*
**
***
****
*****

Reply

CODE FOR THIS PROGRAM
1234321
123*321
12***21
1*****1

Reply

input: i love programming
output: i
love
programming

Reply

can u say how to sum the series

s=1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - x^10/10!

one of the programs in my text plz ans it

Reply

can u plz explain the codes for this??

Reply

can u plz explain the codes of this.. i need it..

Reply

How to create this pattern
int arr = {3,4,-3,5,-6}
Output
___*
____*
*___
_____*
*______

Reply

URGENT!!
How to create this pattern...
int arr = {3,4,-3,5,-6}
Output
___*
____*
*___
_____*
*______

Reply

sir plz help me!!
i/p-I love to study
o/p-I
love
to
study

Reply

hi codenirvana admin!!!!
nice work keep it on...
1*2*3*4
5*6*7*8
9*10*11*12
can u give code for ths

Reply

Please help me.
output: using 3 for loops
xoxoxoxoxoxo
oxoxoxoxoxox
xoxoxoxoxoxo
oxoxoxoxoxox
xoxoxoxoxoxo

Reply

Sir please help me with this.
Can you give the code with the number limit 7?
1
23
456
7

Reply

Sir please help me with this.
Can you give the code with the number limit 7?
1
23
456
7

Reply

how to write a program to display the following pattern
* * * * * * * *
* *
* *
* *
* * * * * * * *
* 1 2 3 *
* 4 5 6 *
* 7 8 9 *
* * * * * * * *



Reply

how to write a program to display the following pattern
* * * * * * * *
* *
* *
* *
* * * * * * * *
* 1 2 3 *
* 4 5 6 *
* 7 8 9 *
* * * * * * * *

Reply

how to write a program to display the following pattern
* * * * * * * *
* *
* *
* *
* * * * * * * *
* 1 2 3 *
* 4 5 6 *
* 7 8 9 *
* * * * * * * *

Reply

how to write a program to display the following pattern
* * * * * * * *
* *
* *
* *
* * * * * * * *
* 1 2 3 *
* 4 5 6 *
* 7 8 9 *
* * * * * * * *
in simply want mobile patern

Reply

print:

A
BB
CCC
DDDD
EEEE....and so on

Reply

Scanner in = new Scanner(System.in);
System.out.println("Enter the Start number to print");
int n=in.nextInt();

int l,j,k,m=5;

for(k=1;k<=m;k++){
/*for(l=1;l<=m;l++){
System.out.print(" ");
}*/
for(j=1;j<=k;j++){
System.out.print(n);
}System.out.println();
n++;
}

try this

Reply

Help me with this pattern (using JOptionPane)
1
1 1 1
1 1 1 1 1
1 1 1 1 1 1 1

Reply

If firstNumber=40; secondNumber=45; thirdNumber=50; WAP to find percentage and division
what is the code of this program

Reply

the code for
12345
2345
345
45
5
is possible as follows:

class N
{
public static void main(String[] args)
{
int k;
for(int i=1;i<=5;i++)
{
k=i;
for(int j=5;j>=i;j--)
{
System.out.print(k);k++;
}
System.out.println();
}
}
}

Reply

how to print this pattern
1234
2341
3412
4123

Reply

how to print this pattern
1234
2341
3412
4123

Reply

can any one tell me the code for A shape

*******
* *
*******
* *
* *

Reply

sir can you help me in doing the following pattern:

if n=4

1
2 4
3 6 9
4 8 12 16

Reply

please give me the code of the following
1
31
531
7531
97531

Reply

Sir can you please solve this...its a request to you..

123456789
2345678
34567
456
5
456
34567
2345678
123456789

Reply

what will be the code for

$$$$$
$$$$$
$$$$$
$$$$$
$$$$$

Reply

what is the code for

$$$$$
$$$$$
$$$$$
$$$$$
$$$$$

Reply

Could you please help me to print the below pattern?

1
2 6
3 7 10
4 8 11 13
5 9 12 14 15


Reply

give me the code for *****
****
***
**
*

Reply

Please print this pattern
1
23
451
2345
12345

Reply

Please print this pattern
1
23
451
2345
12345

Reply

import java.lang.*;
class pattern8
{
public static void main(String args[])
{
for(int i=4;i>0;i--)
{
for(int j=i;j>0;j--)
{
System.out.print(i);
}
System.out.println();
}
for(int i=2;i<=4;i++)
{
for(int j=i;j>0;j--)
{
System.out.print(i);
}
System.out.println();
}
}
}

Reply

how to write a twelve loop program urgent tomarrow i have exam

Reply

how to write a twelve loop program

Reply

plz help for code of below o/p:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Reply

Sir help me to know the code of this output
*****
*
*
*
*****

Reply

help me to find the of this output please
**
**
**
*****
*****

Reply

help me for this pattern
11
12 22
13 23 33
14 24 34 44
15 25 35 45 55

Reply

Sir can you help me to print the pattern
1 1
2 1 1 2
3 2 1 2 3
4 3 3 4
5 5

Reply

class example
{
public static void main(String args[])
{
int i,j, k;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.print(" ");

for(k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}

Reply

class example
{
public static void main(String args[])
{
int i,j, k;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.print(" ");

for(k=i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}

Reply

class big
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++)

{
for(int k=i;k<=5;k++)
{
System.out.print(k);
}
System.out.println();
}
}
}

Reply

class big
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++)

{
for(int k=i;k<=5;k++)
{
System.out.print(k);
}
System.out.println();
}
}
}

Reply

class ss
{
public static void main(String args[])

{

int i,j,k=5;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.print(" ");
for(int m=i;m>=1;m--)
{
System.out.print(m);
}
System.out.println();
}
}
}

Reply

public static void main(String args[])
{
int lineCount = 5;
for (int i = 1; i <= lineCount; i++) {
int value = i;
for (int j = 1; j <= i; j++) {
System.out.print(value + " ");
value += lineCount -j;
}
System.out.println("");
}
}
for :
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

Reply

class ss
{
public static void main(String args[])

{

int i,j,k=5;
for(i=5;i>=1;i--)
{
for(j=i;j>=1;j--)
{
System.out.print(j);
}
System.out.print("_");

for(int m=1;m<=i;m++)
{
System.out.print(m);
}
System.out.println();
}
}
}

Reply

class ss
{
public static void main(String args[])

{

int i,j,k=5;

for(i=1;i<=k;i++)
{
for(j=5;j>=i;j--)
{
System.out.print(j);
}
System.out.println();
}
for(i=4;i>=1;i--)
{
for(j=5;j>=i;j--)
{
System.out.print(j);
}
System.out.println();

}
}
}

Reply

sir can you help me...im doing a program but i want to enhance it...this is the output


1 0 0 0 1
0 1 0 1 0
0 0 1 0 0
0 1 0 1 0
1 0 0 0 1

Reply

can you please give me the snipet for this pattern:
* * * *
* * *
* *
*

Reply

Sir,
Plz help me out with this pattern
*
*#
*#*
*#*#
*#*#*

Reply

Hi.... i want this output..can you please help me...

0 0
1 0
0 1
1 1
2 0
0 2
2 1
1 2
2 2
3 0
0 3
3 1
1 3
3 2
2 3
3 3

Reply

1
3*2
4*5*6
10*9*8*7
11*12*13*14*15

plz get me the code for this

Here is one more solution .
draw(5); // call this method with no. of rows you want to print in such pattern.

private static void draw(int a)
{
int row;
row=a;

int count=1;
List list=new ArrayList();
for(int i=0;i itr = list.iterator();
boolean bool=false;
while(itr.hasNext())
{
if(bool)
{
System.out.print("*");
}

System.out.print(itr.next());
bool=true;

}
list.removeAll(list);
}
else
{
Collections.reverse(list);
Iterator itr = list.iterator();
boolean bool=false;
while(itr.hasNext())
{
if(bool)
{
System.out.print("*");
}

System.out.print(itr.next());
bool=true;

}
list.removeAll(list);
}
System.out.println();
}
}

Reply

hello sir can you help me to print
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3

Reply

hey please someone can you help me to print this pattern
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3

Reply

Plz help me.....

input----- 4
output----

2
3. 5
7 11. 13
17. 19. 23 29

Reply

I'm having trouble making this code:
"Write a program that asks the user for a size and a character, and then outputs a square pattern of that size using the character."

Reply

hello sir!!how to print this pattern?
*
* *
* * *
* * * *
* * * * *


Reply

hello sir!!!!!! how to print rhis pattern??

54321
4321
321
21
1

Reply
This comment has been removed by the author.

Hi is there a code for this:
Write a program that will display the following pattern given the value of n, example if the value of n=5 the output:
.
._.
._._.
._._._.
._._.
._.
.

Reply

Sir, please can you get me the code for the below pattern...

3
23
123
0123
123
23
3

Reply

Sir, please can you get me the code for the below pattern...

3
23
123
0123
123
23
3

Reply

what will be following code

@@@1
@@12
@123
1234

Reply

Dude can you solve this pattern asap

54321
4321
321
21
1


Reply

Dude can you solve this pattern asap

54321
4321
321
21
1


Reply
This comment has been removed by the author.

can you help me with this program?
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Reply

Please help me with this

1 1
12 3
123 6
1234 10
1234515
and
@

@ @

@

Reply

55555
45555
34555
23455
12345
Send Code Please

Reply

what will be the code for below pattern
*
***
*****
*******
*********
***********

Reply

can you please help me with the pattern:

0
2 4
6 8 10
12 14 16 18
20 22 24 28 30

Reply

sir u r great u r doing a good job thank u soo much very helpfull

Reply

can you type the code for
5
454
34543
2345432
123454321
2345432
34543
454
5
as soon as possible

Reply

can you plz help me out to display n rows of the given pattern
1
101
10001
1000001

Reply

i want a pattern
5
4 4
3 3 3
2 2 2 2
1 1 1 1 1

Reply

Hello can any one solve this problem
Print the word BHUPENDRA in star pattern or any other word in star pattern given by user....

Reply

Hello can any one solve this problem Print a big star ★ pattern inside this print asterisk symbol ★

Reply

logic to print the below program
1
2 4 6
3 6 9 12
4 8 12 16 20

Reply

please solve this pattern...
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9

Reply

solve this pattern please...
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9

Reply

sir can i have the code for the following pattern

N
NI
NII
NIIT

thanks and appreciate ...

Reply

What will be the input for this output, Sir?:
1
234
56789

Reply

code please -
s=1+2/2!+3/3!+4/5!+........n

Reply

hey plese help me sir i
i need a travel agency program

Reply

Here is the code for above problem

public class P4
{
public static void main(String [] args)
{
int i,j,count=1,k=0,pos=0;
for(i=0;i<5;i++)
{
k=i;
for(j=0;j<=i;j++)
{
if(i%2==0)
{
if(j!=i)
System.out.print(count + "*");
else
System.out.print(count);
count++;
}
else
{
if(j!=i)
System.out.print(count+k + "*");
else
System.out.print(count+k);
k--;

}

}
if(i%2==1)
count=count+j;
System.out.println();
}
}
}

Reply

public class P4
{
public static void main(String [] args)
{
int i,j,count=1,k=0,pos=0;
for(i=0;i<5;i++)
{
k=i;
for(j=0;j<=i;j++)
{
if(i%2==0)
{
if(j!=i)
System.out.print(count + "*");
else
System.out.print(count);
count++;
}
else
{
if(j!=i)
System.out.print(count+k + "*");
else
System.out.print(count+k);
k--;

}

}
if(i%2==1)
count=count+j;
System.out.println();
}
}
}

Reply

how to write this pattern in java program?
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5

Reply

1
12
123
1234
12345
Pls help me ...

Reply

wap in java to print the pattern 7531
753
75
7

Reply

wap in java to print the pattern 333
55555
7777777
plz comment fast i need it now

Reply

plz tell me the program to print
9 99 999 9999 99999 999999..........n

Reply

all total roman number print in java.
1-100

Reply

What will be the code for this pattern:
* *
********
**********
************
**************

Reply

Sir What will be the code for the pattern
1
2 1
3 2 1
4 3 2 1
5 4 3 2

Reply

0 0 0 0 0 0
1 1 1 1 1
0 0 0 0
1 1 1
0 0
1

Reply

Hi Please provide the solution as soon ass possible
Given an integer N, print N lines of the paFern. If N=4 then -
1*2*3*4*17*18*19*20
--5*6*7*14*15*16
----8*9*12*13
------10*11
Input: n-> Integer number of rows.

Reply

Given an integer N, print N lines of the paSern. If N=4 then -
1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8
Input: n-> Integer number of rows.
Output: Printed paSern in those many number of rows

Reply

Given an integer N, print N lines of the paFern. If N=4 then -
1*2*3*4*17*18*19*20
--5*6*7*14*15*16
----8*9*12*13
------10*11
Input: n-> Integer number of rows.
Output: Printed paFern in those many number of rows

Reply
This comment has been removed by the author.

Calculate the G.C.D of n numbers.
Input: arr -> array of posi8ve integers.
Output: GCD of input array elements.

Reply

Given two 8-bit-characters as input, determine if they can be placed successively in a gray code sequence.
Input: two 8-bit characters.
Output:An integer 1 if the required condi4on is met, 0 if not.

Reply

Hi Try this...............
package test;

public class DesignPattern8 {

public static void main(String[] args) {
int i, j;
int n = 5;
int k = 1;
int temp = 0;

for (i = 1; i <= n; i++) {
if (i % 2 != 0) {
for (j = 0; j < i; j++) {

if (j < i - 1) {
System.out.print(k + "*");
k++;
} else {
System.out.print(k);
k++;
}

}
}
else
{ k=k+i-1;
for(j=0;j<i;j++)
{
if (j < i - 1) {
System.out.print(k + "*");
k--;

} else {
System.out.print(k);
k--;
}
}
temp=temp+2;
k=k+1+temp;
}
System.out.println();
}

}

}

Reply

How to Print the sum of Series in Java?
S=1+(1*2)+(1*2*3)+.........+(1*2*3*.............*20)

Reply

class Temp
{
public static void main(String[] args)
{
int n=4;
for(int i=n;i>0;i--){
for(int j=1;j<=n;j++){
System.out.print(n);
}
System.out.println();
n--;
}
n=2;
for(int i=n+1;i>0;i--){
for(int j=1;j<=n;j++){
System.out.print(n);
}
System.out.println();
n++;
}
}
}

Reply

how to print
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

Reply

*

*A*

*ABA*

*ABCBA*

*ABCDCBA*

*ABCDEDCBA*
i want these codes asap plzzzzz its urgent

Reply

1
21
321
4321
54321
please give the following pattern answer
pleeeeeeeeeeeeeeeeeeeeeeeeeeese

Reply
This comment has been removed by the author.

Hi Prathima
pleas find the code

public class Solution
{
public static void main(String[] args)
{
int i, j;
int n = 4;
int k = 1;
int temp = 0;

for (i = 1; i <= n; i++)
{
for (j = 0; j < i; j++)
{
System.out.print(k);
k--;
}
k++;
temp++;
k=k+i+temp;

System.out.println();
}
}

}

Reply

Code for this :
1 1

1 1

1 1

0

1 1

1 1

1 1
it should come in a X shape. with zero in mid and 1s as the x's lines.....

and for this also :

*

*A*

*ABA*

*ABCBA*

*ABCDCBA*

*ABCDEDCBA*

Thank you :)

Reply

To print
10 20 30
40 50 60
70 80 90

Reply

a
abc
abcd
abcde
for N no. of lines
and when it reaches 'z' again start from 'a'

Reply

a
abc
abcd
abcde
for N no. of lines
and when it reaches 'z' again start from 'a'

Reply

Sir I want a C or java program which should display the following output by taking value n=4
1
2*3
4*5*6
7*8*9*10
4*5*6
2*3
1

Reply

sir plz solve it .
generate the pattern where n can b between 1 to 26.

when n=1
then
_*
*A*
_*
n=2
__*
_*A*
*ABA*
_*A*
__*
...... and so on.

Reply

Sir what is the output for this pattern program.
5
10 20
15 45 135
20 80 320 1280

Reply

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25


how to do this sir...??

Reply

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25


how to do this sir...??

Reply

5
3 4 6
5 8 2 3
3 8 7 2 9
6 1 7 6 2 4
Sir I want a java program which should display the following
addition of highest number in each line
5+6+9+7=27

Reply

public class Pattern_b {


public static void main(String[] args) {
int i,j,r,n=4;
for(i=1,r=n;i<=n;i++,r--){
for(j=n;j>=i;j--){
System.out.print(r);
}
System.out.println();
}
for(i=2;i<=n;i++){
for(j=1;j<=i;j++){
System.out.print(i);
}
System.out.println();
}

}

}

Reply

how to do this-
0405 1213 2021 2829
03 06 11 14 19 22 27 30
02 07 10 15 18 23 26 31
01 0809 1617 2425 32

Reply

for(int k=5-i ; k<4 ; k++){
System.out.print(" ");
}
NO need this part for
12345
2345
345
45
5
if output like this
12345
2345
345
45
5
then only use
for(int k=5-i ; k<4 ; k++){
System.out.print(" ");
}

Reply

Sir I want a java program which should display the following output
BY USING for loop.
1 2 3 4 5
1 5
1 5
1 5
1 2 3 4 5

Reply

Sir I want a java program which should display the following output
BY USING for loop.
1 2 3 4 5
1 5
1 5
1 5
1 2 3 4 5

Reply

Sir I want a java program which should display the following output
BY USING for loop.
1 2 3 4 5
1 5
1 5
1 5
1 2 3 4 5

Reply

public class series {
public static void main (String args[]){

for(int i=1,r=1;i<=5;i++,r++){
for(int j=1;j<=r;j++){
System.out.print(j);
}
if(r==5){System.out.print(" ");}
for(int k=r;k>=1;k--){
System.out.print(k);
}
System.out.println(); }
}
}

Reply

public class series {
public static void main (String args[]){

for(int i=1,r=1;i<=5;i++,r++){
for(int j=1;j<=r;j++){
System.out.print(j);
}
if(r==5){System.out.print(" ");}
for(int k=r;k>=1;k--){
System.out.print(k);
}
System.out.println(); }
}
}

Reply

sir i want your help. the pattern is shown below:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1

Reply

it will get input from user,,
according to our input it will print.....
ie.
Enter any num : 5
if we give 5 as input

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5




if we give any././ according to our input how to modify that

Reply

*****
****
***
**
*


Plz give me code of this pattern

Reply

code for output:
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15

Reply

what is the code for printing
12345
2 4
3 3
4 2
54321

Reply

Sir hep me out
Write the java program for the pattern below
1
2*3
4*5*6
7*8*9*10
11*12*13*14*15

Reply

Sir Help me with this
Write the program for the pattern below
1
3*2
4*5*6
10*9*8*7
11*12*13*14*15

Reply

for n=5
*_*_*
_***_
*****
_***_
*_*_*

for n=7

*__*__*
_*_*_*_
__***__
*******
__***__
_*_*_*_
*__*__*

_=space
Please help! :)

Reply

001
010
100

pattern print in java?

Reply

can u help with dis

******
* *
* *
* *
******

Reply

Plz can u help me with this
1
101
10001
1000001

Please get me a sloution for this code

Reply

Plz can u help me with this
1
101
10001
1000001

Please get me a sloution for this code

Reply


input: 3

output:
3 3 3 3 3
3 2 2 2 3
3 2 1 2 3
3 2 2 2 3
3 3 3 3 3

anyone can answer?

Reply

input:4
output:
4 4 4 4 4 4 4
4 3 3 3 3 3 4
4 3 2 2 2 3 4
4 3 2 1 2 3 4
4 3 2 2 2 3 4
4 3 3 3 3 3 4
4 4 4 4 4 4 4

can anyone try it out?
plzz give me code.

Reply

can u give me code for
*****
* *
* *
* *
*****
*123*
*456*
*789*
*****

Reply
This comment has been removed by the author.

plz
help to print
I
C S
E E E
X A M S

Reply

for above program output is displayed as :
111112
222223
333334
444445
555556
666667

But as per problem statement is should be displayed as follow ;

111112
322222
333334
544444
555556
766666

Reply

package com.pattern;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Pattern5 {

public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
System.out.println("Enter a number");
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
Integer n = Integer.parseInt(bufferRead.readLine());

for (int i = 0; i <=n; i++) {
for (int j = i + 1; j <=n; j++) {
System.out.print(j);
}
System.out.println("");
}
}

}

Reply

package com.pattern;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Pattern6 {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
System.out.println("Enter a number");
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
Integer n = Integer.parseInt(bufferRead.readLine());

for (int i = n; i >0; i--) {
for (int j = 0; j <i; j++) {
System.out.print(i);
}
System.out.println("");
}
for (int i = 2; i <=n; i++) {
for (int j = 0; j <i; j++) {
System.out.print(i);
}
System.out.println("");
}
}

}

Reply

What will be the code for this pattern:

1
131
13531
1357531
13531
131
1

Reply


public class NumberPattern
{

public static void main(String args[])
{
int i,j,k,g=1,n=4,p=2,f=2,b=3,r=5;
for(i=1;i<=7;i++)

System.out.print(" "+n);

System.out.println();

for(j=1;j<=5;j++)
{
for(k=4;k>=3;k--)
//if(k==4 || k==3 )

System.out.print(" "+k);

for(int d=r-j;d>=-1;d--)
{
if(d==4)
System.out.print(" "+b);
if(d==3)
System.out.print(" "+f);
if(d==2)
System.out.print(" "+d);
if(d==1)
System.out.print(" "+f);

else if(d==0)
System.out.print(" "+b);
break;
}

for(int d=r-j;d>=-1;d--)
{
if(d==4)
System.out.print(" "+b);
if(d==3)
System.out.print(" "+f);
if(d==2)
System.out.print(" "+g);
if(d==1)
System.out.print(" "+f);

else if(d==0)
System.out.print(" "+b);
break;
}

for(int d=r-j;d>=-1;d--)
{
if(d==4)
System.out.print(" "+b);
if(d==3)
System.out.print(" "+f);
if(d==2)
System.out.print(" "+d);
if(d==1)
System.out.print(" "+f);

else if(d==0)
System.out.print(" "+b);
break;
}
for(k=3;k<=4;k++)
//if(k==4 || k==3 )

System.out.print(" "+k);


System.out.println();

}
for(i=1;i<=7;i++)

System.out.print(" "+n);

}}



Reply

int count=0;
for(int i=1;i<9;i++){
for(int j=1;j<=2*i-1;j++){
if(i>j||i==j){
count=count+1;
System.out.print(count);
}
else{
count=count-1;
System.out.print(count);
}

}

System.out.println();
}

Reply

int count=0;
for(int i=1;i<9;i++){
for(int j=1;j<=2*i-1;j++){
if(i>j||i==j){
count=count+1;
System.out.print(count);
}
else{
count=count-1;
System.out.print(count);
}

}

System.out.println();
}

Reply

can u pls tell about this
1234554321
1234 4321
123 321
12 21
1 1

Reply

HI CAN YOU PLEASE SEND ME THE CODE TO PRINT THE FOLLOWING PATTERN

6 6 6 6 6 5
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

Reply

code for following pattern
1) 12345
2345
345
45
5
2) 1
21
321
4321
54321

Reply

what will be the program for pattern
1
212
32123
4321234
543212345

Reply
This comment has been removed by the author.

Hello Sir,
i want to print following pattern
1
1 0
1 0 0
1 0 0 0
1 0 0 0 0

Reply

if 'i' incremented then 's' will also increment isn't it

Reply

program for
5
5
55555
5
5

Reply

package num;

public class numericale {
public static void main(String args[]){

int i,j,k=1,rows;
rows=4;

for(i=1;i<=rows;++i)
{
for(j=1;j<=i; j++,k++)
{
System.out.print(k);
}
System.out.println();
}


}
}

Reply

package num;

public class numericale {
public static void main(String args[]){

int i,j,k=1,rows;
rows=4;

for(i=1;i<=rows;++i)
{
for(j=1;j<=i; j++,k++)
{
System.out.print(k);
}
System.out.println();
}


}
}

Reply

i want this pattern how to make it..

***********
***** *****
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
***** *****
***********

Reply
«Oldest   ‹Older   401 – 600 of 1223   Newer›   Newest»

Make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.