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   601 – 800 of 1223   Newer›   Newest»

please give me the source code for displaying the following pattern

123454321
1234 4321
123 321
12 21
1 1

Reply

sir please tell me how to make swastika sign by using numbers 1 to 5

Reply

sir please tell me how to make swastika sign by using numbers 1 to 5

Reply

pls help me solve this pattern-:
9 7 5 3 1
..7 5 3 1
....5 3 1
......3 1
........1
1 1 1 1 1

thank you

Reply

I want solution for this
1
10
101
1001
10001

Reply

Please give the code for this

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

Reply

Hi Suchita try this code.

import java.util.*;
import java.io.*;
import java.util.Scanner;
public static void main(String args[])
{
int i,j,n,p=1,odd=1;
System.out.println("Enter Rows ");
Scanner s=new Scanner(System.in);
n=s.nextInt();
for(i=1;i<=n;i++)
{
for(j=1;j<=odd;j++)
{
System.out.println(p++);
}
System.out.println("");
odd=odd+2;
}
}

Reply

Hello, please can you help me out with this program :-)
If n=7

A _ _ _ 1 _ _ _ A
B _ _ 2 _ 3 _ _ B
C _ 4 _ _ _ 5 _ C
D 6 _ _ _ _ _ 7 D
E _ 8 _ _ _ 9 _ E
F _ _ 10 _ 11 _ _ F
G _ _ _ 12 _ _ _ G

Reply

what is the code for getting this output
1
2 3
6 5 4
7 8 9 10
14 13 12 11

Reply

I want this kind of output but in triangle pattern...
plzz give me the solution

2
4 6
8 10 12
14 16 18 20

Reply

plz tell me how to print this pattern

999999999999999999
88888888 88888888
7777777 7777777
55555 55555
4444 4444
333 333
22 22
1 1

Reply

SIR PLEASE GIVE ME THE SOLUTION
1
1 0 2
1 0 2 0 3
1 0 2 0 3 0 4
1 0 2 0 3
1 0 2
1

Reply

i want pattern of
1
121
12321
till n lines

Reply

code for this pattern??
1
3 5
7 9 11

Reply

what about this pattern:
11111
2222
333
44
5

Reply

I need this type

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

Reply

Please solve this pattern

#$#$#
#$#$
#$#
#$
#

Reply

Hi I need to print
1
2*3
4*5*6
7*8*9*10
7*8*9*10
4*5*6
2*3
1
This particular pattern is not solved earlier

Reply

what about this pattern:
11111
2222
333
44
5

Reply

Hello there...
Please try out this code:

class Pattern4
{
public static void main ()
{
for (int i=0;i<5;i++)
{
for (int j=1;j<=5-i;j++)
{
System.out.print(j);
}
for (int space=1;space<=i;space++)
{
System.out.print(" ");
}
for (int k=5-i;k>=1;k--)
{
System.out.print(k);
}
System.out.println();
}
}
}



Reply

Hello there...
Try this:

class CodeNirvana
{
public static void main(int n)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}

Reply

Hello there...
Here you go....

class CodeNirvana2
{
public static void main(int n)
{
for(int i=1;i<=n;i++)
{

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

Reply

Hey how to print the following pattern:
* *
* *
*
* *
* *

Reply

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

Sir can you tell me what will be the code of above pattern?

Reply

Hi can you kindly help me with this java code the (.) are spaces
......1
.....12
....123
...1234

Reply

And this one please
....1
...1 2
..1 2 3
.1 2 3 4

Reply

sir please help me fast with this program

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

Reply

Hi Sir,

Can you please give me the code for the pattern
----------------11
-------------11 10 11
----------11 10 9 10 11
-------11 10 9 8 9 10 11

please can you help to the earliest possible. It would be great help Sir.

Thanks in advance.


Reply

i can want print in
55555
4444
333
22
1

Reply

what is the code to print for this pattern???????????
1
3 5
7 9 11 13

Reply

print below pattern in java code

*
++
***
++++
*****

please reply soon

Reply

if user input 3 then it should print like this
*
***
*
if 5 then,
*
***
*****
***
*

please send me the code

Reply
This comment has been removed by the author.

plz help me for following pattern
2
4 4 4
6 6 6 6 6
8 8 8 8 8 8 8

Reply


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

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

Reply

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

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

Reply

my pattern is :

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

Reply

sir, the patterns are not coming horizontal, it comes as vertical. please help

Reply

sir, the patterns are not coming horizontal, it comes as vertical. please help

Reply

1
122
122333
1223334444
give me the code for this pattern

Reply

1
122
122333
1223334444
give me the code for this pattern

Reply

pls solve this pattern

@ @
@ @
@ @
@
@ @
@ @
@ @

Reply

123456787654321
1234567_7654321
123456___654321
12345_____54321
1234_______4321
123_________321
12___________21
1_____________1

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

Hi could you help me to figure out the code for this:
1
123
12345
123
1
for odd number
now for even number:
1
123
123
1
Diamond shaped with user input

Reply

Sir please me in this pattern.
-------1
------232
-----34545
----4567654
---567898765
--67890109876
-7890123210987
890123454321098

Reply

Sir could you help me out with this pattern printing
* * * * * * *
* * or * *
* * * * * * *

Reply

i need some help, we are hosting an java event at our college ..
in our event who can find out more bugs in the program he/she wins the contest, so a simple and big program containing more errors but with complex logic..
so please help us ... our event date is on 14/03/2016.

Reply

4321
432
43
4

and

4321
321
21
1

Can you help me please ? thank you

Reply

4321
432
43
4

and

4321
321
21
1

Can you help me please ? thank you

Reply

/*
/4321
/321
/21
/1
*/
import java.util.Scanner;
class program
{
public static void main(String [ ] args)//n is 4 here.
{
System.out.print ("Enter Range: ");
Scanner sx=new Scanner(System.in);
int n=sx.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=n-i+1;j>=1;j--)
System.out.print(j);

System.out.println();
}
}
}

/*
/4321
/432
/43
/4
*/
import java.util.Scanner;
class OK
{
public static void main(String [ ] args)
{
System.out.println(" Enter Range");
Scanner ab=new Scanner (System.in);
int n=ab.nextInt();

for(int i=1;i<=n;i++)
{
for(int j=n;j>=i;j--)
System.out.print (j);

System.out.println();
}
}
}

Reply

/*
/4321
/321
/21
/1
*/
import java.util.Scanner;
class program
{
public static void main(String [ ] args)//n is 4 here.
{
System.out.print ("Enter Range: ");
Scanner sx=new Scanner(System.in);
int n=sx.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=n-i+1;j>=1;j--)
System.out.print(j);

System.out.println();
}
}
}

/*
/4321
/432
/43
/4
*/
import java.util.Scanner;
class OK
{
public static void main(String [ ] args)
{
System.out.println(" Enter Range");
Scanner ab=new Scanner (System.in);
int n=ab.nextInt();

for(int i=1;i<=n;i++)
{
for(int j=n;j>=i;j--)
System.out.print (j);

System.out.println();
}
}
}

Reply

1
32123
4321234
543212345
4321234
32123
212
1

Reply

1
212
32123
4321234
543212345
4321234
32123
212
1

Reply

What will be the code for
*
***
*****
*******
*********

Reply


This the required code


This the required code


class j
{
public void main()
{//upper part
int i=1;int p=5;

for(i=1;i<=p;i++)
{int l=i;

if(l>1)
{
for(;l>=1;l--)
{System.out.print(l);
}
for(int k=2;k<=i;k++)
{
System.out.print(k);
}
}
else
System.out.print(1);
System.out.println();
}
//lower part
for(int a=4;a>=1;a--)
{
int b=a;
if(b>1)
{
for(;b>=1;b--)
{
System.out.print(b);
}
for(int k=2;k<=a;k++)
{
System.out.print(k);
}
}
else
System.out.print(1);
System.out.println();
}}}



class j
{
public void main()
{//upper part
int i=1;int p=5;

for(i=1;i<=p;i++)
{int l=i;

if(l>1)
{
for(;l>=1;l--)
{System.out.print(l);
}
for(int k=2;k<=i;k++)
{
System.out.print(k);
}
}
else
System.out.print(1);
System.out.println();
}
//lower part
for(int a=4;a>=1;a--)
{
int b=a;
if(b>1)
{
for(;b>=1;b--)
{
System.out.print(b);
}
for(int k=2;k<=a;k++)
{
System.out.print(k);
}
}
else
System.out.print(1);
System.out.println();
}}}

Reply


class j
{
public void main()
{
int i =1;
int j=3;
int k=1;
for(i=1;i<=j;i++)
{
for( k=1;k<=j;k++)
{
System.out.print(k);
}
System.out.println();
}
}

Reply

hi sir can please send the code for this diamond format:
1
2 3
4 5 6
7 8
9

Reply

hi sir can u please write the code for the below format
1
2 3
4 5 6
7 8
9

Reply

this pattern is in diamond shape

Reply
This comment has been removed by the author.

Please help me out with this program:

If number of rows = 5,

1
1 2
1 2 5
1 2 5 12
1 2 5 12 29
1 2 5 12 29 70

Reply

int value=1;
System.out.println("Enter row count");
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int space=n-1;
for (int i = 1; i <= n; i++) {

for (int j = 1; j <= space; j++)
System.out.print(" ");
space--;


for (int k=1;k<=i;k++){
System.out.print(value+" ");

value++;
}

System.out.println();
}

int count=1;


for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= count; j++)
System.out.print(" ");
count++;
for (int k = 1; k <=n-i; k++)
{

System.out.print(value+" ");;
value++;
}
System.out.println();


}




}
}

Reply

hi , can you make a code of this one.

3
3 3
3 3 3
3 3 3 3

Reply

public class stars {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("enter n");
int n= in.nextInt();
for (int i=0;i<=n;i++){

for (int j=0;j<=i;j++){
System.out.print("3");

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

Reply

Hi sir i got the pgm for how to print the this diamond pattern .can u please write the code for adding the column elements for this pattern

Reply

plzzzz tell me code of this pattern
2
2 4
2 4 6
2 4 6 8
2 4 6 8 10

Reply

plzzzz tell me code of this pattern
2
2 4 6
2 4 6 8
2 4 6 8 10

Reply

Hey!
Kindly tell how to code this pattern?
5 4 3 2 1
10 8 6 4 2
15 12 9 6 3

Reply

Hey the output is
1
01
010
1010
10101

Reply

Hello, sir plz help me for the following pattern
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Reply

Hello, sir plz help me for the following pattern
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Reply

class k
{
public void main()
{

for(int i=1;i<=5;i++)
{int c=1;
if(i%2==0)
{
for(int j=2;c<=i;j=j+2,c++)
{
System.out.print(j);
}
}
else
{
for(int j=1;c<=i;j=j+2,c++)
{
System.out.print(j);
}
}
System.out.println();
c=1;
}

}

}

Reply

class k
{
public void main()
{
int k=0;
for(int i=1;i<=5;i++)
{
if(i==1){

k=1;
System.out.print(k);
System.out.println();
k=0;
continue;
}


int c=1;
if(i==4||i==5)
{
for(int j=1;c<=i;c++)
{
if(j==0)
{

System.out.print(j);
j=1;
}




else if(j==1)
{

System.out.print(j);
j=0;
}
}
}
else
{
for(int j=0;c<=i;c++)
{
if(j==0)
{

System.out.print(j);
j=1;
}




else if(j==1)
{

System.out.print(j);
j=0;
}
}
}

System.out.println();
c=1;


}
}
}











Reply

class k
{
public void main()
{
int k=0;
for(int i=1;i<=5;i++)
{
if(i==1){

k=1;
System.out.print(k);
System.out.println();
k=0;
continue;
}


int c=1;
if(i==4||i==5)
{
for(int j=1;c<=i;c++)
{
if(j==0)
{

System.out.print(j);
j=1;
}




else if(j==1)
{

System.out.print(j);
j=0;
}
}
}
else
{
for(int j=0;c<=i;c++)
{
if(j==0)
{

System.out.print(j);
j=1;
}




else if(j==1)
{

System.out.print(j);
j=0;
}
}
}

System.out.println();
c=1;


}
}
}











Reply

Hi sir i need code for this pattern using java .

1827364554637281
17263544536271
162534435261
1524334251
14233241
132231
1221
11

Reply

Hi! Can I get a solution for the following pattern:

A

Z Y

B C D

X V U W

E F G H I

Reply

Please Help me with this

A B C
A B C
A B C

and

11 12 13
21 22 23
31 32 33

Thanks

Reply

Please help me with

A B C
A B C
A B C

and

11 12 13
21 22 23
31 32 33

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 9;
System.out.println("---------------------------");
System.out.println("Pattern: a");
System.out.println("---------------------------");
System.out.println("");
for (int i= 1; i <= size; i++) { // Outer loop to print all the rows

for (int j = 1; j <= size; j++) { // Inner loop to print all the columns of each row
if((i==1)|| (i==size)||(j==1)||(j==size))
{

System.out.print("1");
}
else

if((i==2)|| (i==size-1)||(j==2)||(j==size-1))


System.out.print("2");
else

if((i==3)|| (i==size-2)||(j==3)||(j==size-2))


System.out.print("3");

else

if((i==4)|| (i==size-3)||(j==4)||(j==size-3))


System.out.print("4");
else

if((i==5)|| (i==size-4)||(j==5)||(j==size-4))


System.out.print("5");
else
System.out.print(" ");
System.out.print(" ");
}

// A row ended, bring the cursor to the next line
System.out.println();
}
}
}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5;
System.out.println("---------------------------");
System.out.println("Pattern: a");
System.out.println("---------------------------");
System.out.println("");
for (int i= 1; i <= size; i++) { // Outer loop to print all the rows

for (int j = 1; j <= size; j++) { // Inner loop to print all the columns of each row
if((i==1)|| (i==size)||(j==1)||(j==size))


System.out.print("1");


else

System.out.print("0");
System.out.print(" ");
}
// A row ended, bring the cursor to the next line
System.out.println();
}
}
}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5, size1=5;

for (int i= 1; i <=size1; i++) { // Outer loop to print all the rows

for (int j = 1; j <= size; j++) { // Inner loop to print all the columns of each row

System.out.print(i);



System.out.print(" ");

}

// A row ended, bring the cursor to the next line
System.out.println();
size=size-1;
}
}
}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5, size1=5;

for (int i= 1; i <=size1; i++) { // Outer loop to print all the rows

for (int j = 1; j <= size; j++) { // Inner loop to print all the columns of each row

System.out.print(i);



System.out.print(" ");

}

// A row ended, bring the cursor to the next line
System.out.println();
size=size-1;
}
}
}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 7; //max no. of series
for(int i=1;i<=size;i++){

for(int j=1;j <=i;j++){
System.out.print("*");

}
System.out.println();
i=i+1;

}

for(int i=size-2;i>=1;i--){

for(int j=1;j <=i;j++){
System.out.print("*");

}
System.out.println();
i=i-1;

}

}


}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 4; //max no. of series
for(int i=size;i>=1;i--){

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

}
System.out.println();
// i=i+1;

}

for(int i=2;i<=size;i++){

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

}
System.out.println();
// i=i-1;

}

}

}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 4; //max no. of series
for(int i=size;i>=1;i--){

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

}
System.out.println();
// i=i+1;

}

for(int i=2;i<=size;i++){

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

}
System.out.println();
// i=i-1;

}

}

}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 4; //max no. of series
for(int i=size;i>=1;i--){

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

}
System.out.println();
//i=i-1;

}


for(int i=2;i<=size;i++){

for(int j=2;j<=i+1;j++){
System.out.print(i+" ");

}
System.out.println();
// i=i+1;

}


}

}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5; //max no. of series
for(int i=1;i<=size;i++){

for(int j=i;j <=size;j++){
System.out.print(j+" ");

}
System.out.println();
// i=i+1;

}


}


}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5; //max no. of series
int i;
for( i=size;i>=1;i--){

for(int j=1;j <=i;j++){

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


}



for(int j=i;j >=1;j--){

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

}
System.out.println();

}


}


}

Reply

public class PrintSquarePattern { // Save as "PrintSaurePattern.java"
public static void main(String[] args) {
int size = 5; //max no. of series
int i;
for( i=1;i<=size;i++){

for(int j=1;j <=i;j++){

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


}



for(int j=i;j >=1;j--){

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

}
System.out.println();

}


}


}

Reply

public class JavaCodez { // Save as "JavaCodez.java"
public static void main(String[] args) {
int size = 9; //max no. of series
for(int i=1;i<=size;i++){

for(int j=1;j <=i;j+=2){
System.out.print(j+" ");

}
System.out.println();
i=i+1;

}

}


}

Reply

public class JavaCodez { // Save as "JavaCodez.java"
public static void main(String[] args) {
int size = 5;
for (int i= 1; i <=5; i++) { // Outer loop to print all the rows
for (int j = 1; j <=i; j++) { // Inner loop to print all the columns of each row
System.out.print(size);
System.out.print(" ");
}
// A row ended, bring the cursor to the next line
System.out.println();
size=size-1;
}
}
}

Reply

public class JavaCodez{ // Save as "JavaCodez.java"
public static void main(String[] args) {
int size = 5; //max no. of series
for(int i=1;i<=size;i++){
for (int k=1;k<=i;k++)
{
System.out.print(i+" ");
}
for(int j=i+1;j <=size;j++){

System.out.print(j+" ");
}
System.out.println();
}
}
}

Reply

1
232
34543
4567675

and

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

Reply

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

and
1
232
34543
4567675

Reply

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

and
1
232
34543
4567675

Reply

1
232
34543
4567675

and

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

Reply

WHAT WILL BE THE OUTPUT FOR
13579
35791
57913
79135
91357

Reply

class pattern
{

public static void main(String args[])
{
int r=0,c=0;

for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(c);
}
for(c=r;c>=1;c--)
{
System.out.print(c);
}
System.out.println();
}
}
}

Reply

Here's the code for the program you mentioned :

class pattern
{

public static void main(String args[])
{
int r=0,c=0;

for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(c);
}
for(c=r;c>=1;c--)
{
System.out.print(c);
}
System.out.println();
}
}
}

Reply

Sir can you please give me the code for this......thank you:)
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Reply

Sir can you please give me the code for this......thank you:)
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Reply

How to solve this program
O o
Ob. bo
Obj. jbo
Obje ejbo
Objec cejbo
Objectcejbo
Objec cebjo
Obje. ejbo
Obj. jbo
Ob. bo
O. O

Reply

public class Sumit {
public static void main( String arg[]){
for(int i=1 ; i<=5 ; i++){
/*for(int k=5-i ; k<4 ; k++){
System.out.print(" ");
}*/
for(int j=i ; j<=5 ; j++){
System.out.print(j);
}
System.out.println();
}
}
}

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

Hey this should be the correct pattern to your requirement ,
Output for ---

11111112
32222222
33333334
54444444
55555556
76666666

-----------------
Executed properly ,any input you can give.

public class comment
{
public static void main (String args[])
{
int n = 6; //change to ypur requirement(should be even nos)
int count1=1,count2=2,x=n;
while(x>0){
for(int i=1;i<n;i++){
System.out.print(count1);
}
count1++;
System.out.print(count2++);
System.out.println();
System.out.print (count2++);
for(int j=1;j<n;j++){
System.out.print(count1);
}
System.out.println();
count1++;
x-=2;
}
}
}

Reply

can you tell me the program accept a number x from the user and number on terms n also from the user
and find
x!/10 + (x+2)!/15 + (x+4)!/20 .... till n terms

Reply

can you tell me the program accept a number x from the user and number on terms n also from the user
and find
x!/10 + (x+2)!/15 + (x+4)!/20 .... till n terms

Reply

help me for this pattern....

"1357
135
13
1"

Reply

1
23
4567
89123456
7891234567891234
How can i print the numbers?

Reply

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

Reply

hi sir u r just great in this . i want to ask how to create logic for making patterns. give me an example plzzz if u can .how to start making logic

Reply

hi sir u r just great in this . i want to ask how to create logic for making patterns. give me an example plzzz if u can .how to start making logic

Reply

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
mobulous software pvt. ltd. program for aptitude.

Reply

what is the code for this pattern
1
2 3
3 4 5
5 6 7 8
8 9 10
10 11
11

Reply

Kindly Help Me
Give me Code to print This type of pattern...

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

Reply

1
123
12345
1234567
12345
123

How to solved it plzzzzzzzzz

Reply

1
123
12345
1234567
12345
123
1


plesae genarate code in java help me

Reply

int i,j;
for(i=1 ; i<=5 ; i++){
for(j=i;j<=5;j++)
System.out.print(j);
System.out.print("\n");
}

why did you use k there? could you please explain me? because mine is working properly.

Reply

how to print the pattern :-\

1
3 1
5 3 1
7 5 3 1
9 7 5 3 1

Reply

how to print the pattern :-\

1
3 1
5 3 1
7 5 3 1
9 7 5 3 1

Reply

Sir Please solve this program
input:Hi Sir this is pattern code
output:H i i t

Reply

package Basic;
/**
* program to display above pattern in java
* @author SK
* */
public class NumberPatterns {
public static void main(String[] args) {
/*---------first part----------------*/
for(int i=5;i>=1;i--){
for(int j=1;j<=i;j++){
if(j<=i)
System.out.print(j+" ");
else
System.out.print(" ");
}
for(int k=4;k>=1;k--){
if(k>i)
System.out.print(" ");
else
System.out.print(k+" ");
}
System.out.println();
}
/*---------second part----------------*/
}
}

Reply

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

Reply

please give the code for
0
10
101
0101
01010
and
1
0 1
0 10
1 010
1 0101

Reply

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

Reply

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

Reply

what is the code for this?
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9
2 4 6 8 10 12
1 3 5 7 9 11 13

Reply

What is the code for this pattern?
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9
2 4 6 8 10 12

Reply

here is the simple code

class NumberPattern
{
public static void main( String arg[]){

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

Reply

here is the solution

class NumberPattern1
{
public static void main( String arg[]){

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

Reply

here is the solution

class NumberPattern1
{
public static void main( String arg[]){
for(int i=1;i<=5;i++)
{
for(int j=i;j<=5;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}

Reply

what will be the solution for 1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
using switch case

Reply

any body can give the code for following pattern..
1*2*3*4*5*26*27*28*29*30
6*7*8*9*22*23*24*25
10*11*12*19*20*21
13*14*17*18
15*16

Reply

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

Reply

please show me the pattern of :
1
21
321
4321
54321

Reply

plzzzz tell me code of this pattern by while
*
##
***
####
*****

Reply

plzzzz tell me code of this pattern by while
*
##
***
####
*****

Reply

plz can u help this pattern?

1
22
333
4444
55555

give me code

Reply

plz can u help this pattern?

1
22
333
4444
55555

give me code

Reply

public class Pattern5 {

public static void main(String[] args) {
System.out.println("Enter a number for pattern");
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
for(int i=0;i<n;i++){
for(int j=(i+1);j<=n;j++){
System.out.print(j);
}
System.out.println();
}

}

}

Reply

write a java program
Method should accept two parameters.
First parameter is first number to display, second parameter should be number of rows to be printed.


printseries(firstparam,secondparam)

Sample:
printseries(7,4)

Output should be:
7
14 15
28 29 30 31
56 57 58 59 60 61 62 63

Reply

Below program prints format of
what is the purpose of c=2,while(c>0) and c-- can you please explain this
12345
1234
123
12
1
12
123
1234
12345


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

}
}

Reply

SIR CAN PLEASE TELL METHE CODE OF TH BLOW NUMBER PYRAMID:
1
12
123
1234

Reply

SIR CAN PLEASE TELL METHE CODE OF TH BLOW NUMBER PYRAMID:
1
12
123
1234

Reply

SIR CAN PLEASE TELL METHE CODE OF TH BLOW NUMBER PYRAMID:
1
12
123
1234

Reply

What will be the code for:
Pattern 1:
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

Pattern 2:
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16
?

Reply

give me code for following patterns
1.
1 3 8 15
24 35 48
63 80
99
2.
1 8 27
64 125 216
343 512 729
3.
0 2 4
6 10 12
18 22 28
30 36 40
please give it quick.....

Reply

int p = 1;
for(int i = 1; i<=3; i++)
{
for(int j=1; j<=3; j++)
{
System.out.print(p);
p++;
}

System.out.println();
}

Reply

SIR PLEASE SOLVE THIS PROGRAM
1 2 3
8 4
7 6 5

Reply

SIR PLEASE SOLVE THIS PROGRAM
1 2 3
8 4
7 6 5

Reply
This comment has been removed by the author.

need your help to print
20 19 18 17 16
11 12 13 14 15
10 9 8 7 6
1 2 3 4 5

Reply

I need help please solve the pattern:-X1Z2X3Z4
X5Z6X7
X8Z9
X10

Reply

what was code for

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

Reply

Hi sir i want to print this pattern and all the 5 must be in centre line
5
4 5 4
3 4 5 4 3
2 3 4 5 4 3 2
1 2 3 4 5 4 3 2 1
2 3 4 5 4 3 2
3 4 5 4 3
4 5 4
5

Reply

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1

Reply

sir i want a java program to print the pattern of even numbers
2 2
4 4 4 4
6 6 6 6 6 6

Reply

String str="asdasfwtr"; , i want to know how many times each letter is occurred in a string

Reply

how to make this without array
123
8 4
765

Reply

hiii sir .........pls help me to make a pattern

Reply

how to print this..
1234567
654321
12345
4321
123
21
1

Reply

pls sir help
how to print this.......
1
23
4567
89123456
7891234567891234

Reply

how to print it...
12345678
8765432
234567
76543
3456
654
45
5

Reply

54321
4321
321
21
1

sir pls tell me the code asap !!

Reply

please Help me

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

Reply
This comment has been removed by the author.

what is the pattern for:::::

1
12
121
12321
1234321
123454321
1234321
12321
121
12
1

Reply

a a^2 a^3
1 1 1
2 4 8
3 9 27
4 16 64

Reply

can i get for this 01
120
130

Reply

Sir Can You please solve this program !
If input = 4 then ,
Output:
4444444
4333334
4322234
4321234
4322234
4333334
4444444

Reply

plz help me out for this program & explain it sir!!!
1
2 2
3 3 3
4 4 4 4

Reply

please help me to solve this problem!!
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Reply

hello sir plzzz help me how to print this type.

001
010
100

Reply
This comment has been removed by the author.

Can u pls help me in printing following pattern
if input=4

1 0 0 0
2 2 0 0
3 3 3 0
4 4 4 4
Reply

Reply

public class Test {

public static void main(String[] args) {
int l=0;
for(int i=0; i<4; i++){
for(int j=0; j<4; j++){
if(l>=j){
System.out.print(l+1);
}else
System.out.print("0");
}
l++;
System.out.print("\n");
}

}

}

Reply
This comment has been removed by the author.
«Oldest   ‹Older   601 – 800 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.