While doing pattern using any program, we have to use nested loop. Here one point to be kept in mind that while using nested loops to form pattern, outer loop controls the rows and the inner loop controls the columns. The designing part of any pattern is solely dependant on inner loop. So the printing part job is always done by the inner loop. After studying the pattern, execute the outer loop to generate rows. But the main job is done by the inner loop. So you have to think very deeply about the inner loop designing.
123454321
1234 4321
123 321
12 21
1 1
class pt1
{
int i,j,k,m,x;
void show()
{
for(i=0;i< 5;i++)
{
x=1;
for(j=i;j< 5;j++)
System.out.print(x++);
for(k=0;k< i; k++)
System.out.print(" ");
x=x-1;
for(m=i;m< 5;m++)
System.out.print(x--);
System.out.println();
}
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
Download eBook on BlueJ
This above pattern is displayed using three inner loops inside the outer loop. Outer loop as usual generates the rows. First inner loop displays one digit more than that of the third inner loop. The middle inner loop displays the blank spaces of the pattern. Each time the first inner loop starts with '1' and go on incrementing. When the control leaves the first inner loop the middle inner loop catches the control. Again the third inner loop starts from a value less than 2 of the last value of the loop control variable of first inner loop.
Next program on pattern
1 1
12 3
123 6
1234 10
12345 15
class pt1
{
int i,j,k,m,x;
void show()
{
x=0;
for(i=1;i< =5;i++)
{
for(j=1;j< =i;j++)
{
System.out.print(j);
}
x=x+i;
System.out.println(" "+x);
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
Next program on pattern
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
class pt1
{
int i,j,k,m,x;
void show()
{
for(i=0;i< 4;i++)
{
for(j=i;j< 3;j++)
{
if(j==0)
System.out.print(" ");
else
System.out.print(" ");
}
x=1;
for(k=0;k< =i*2;k++)
{
if(k%2==0)
System.out.print(x++);
else
System.out.print(" ");
}
System.out.print(" ");
x=x-2;
for(m=0; m < i*2; m++)
{
if(m%2==0)
System.out.print(x--);
else
System.out.print(" ");
}
System.out.println();
}
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
OR
class pt1
{
int i,j,k,m,x;
void show()
{
for(i=0;i< 4;i++)
{
for(j=i;j< 3;j++)
{
System.out.print(" ");
}
x=1;
for(k=0;k< =i;k++)
{
System.out.print(x++);
x=x-2;
for(m=0; m< i;m++)
{
}
System.out.println();
}
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
*****
***
*
***
*****
*******
class pt1
{
int i,j,k,m,x;
void show()
{
x=7;
for(i=0;i< 4;i++)
{
for(j=0; j < i;j++)
System.out.print(" ");
System.out.print("*");
x=x-2;
for(j=0; j< i;j++)
System.out.print(" ");
System.out.println();
}
for(i=0;i< 4;i++)
{
for(j=i+1;j< 4;j++)
System.out.print(" ");
System.out.print("*");
x=x+2;
for(j=i+1;j< 4;j++)
System.out.print(" ");
System.out.println();
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
In this program also, inner loop creates this pattern. This pattern consists of two nested loops and within each outer loop, the first inner loop prints space at the left side and the second inner loop prints the star symbols. After each iterations, the inner loop execution decreases. The first nested loop prints the pattern upto the single star symbol. The other nested loop prints the lower part of the program. Here the inner loop execution increases after each iterations.
This site is on Bluej for icse schools. If you have any doubt in any program, pl. feel free to put your comments. I am here to clear your doubts.
print :
ReplyDelete55555
54444
54333
54322
54321
Two Programs of the above pattern
ReplyDeleteclass pat
{
public static void main(String args[])
{
int i,j,k,x;
for(i=0;i<5;i++)
{
x=5;
for(j=0;j<i;j++)
System.out.print(x--+" ");
for(k=i;k<5;k++)
System.out.print(x+" ");
System.out.println();
}
}
}
OR
class pat
{
public static void main(String args[])
{
int i,j,x;
for(i=0;i<5;i++)
{
x=5;
System.out.print(x+" ");
for(j=0;j<5;j++)
{
if(j<i)
x--;
System.out.print(x+" ");
}
System.out.println();
}
}
}
Oh! A silly mistake in the second program. Modified.....
ReplyDeleteclass pat
{
public static void main(String args[])
{
int i,j,x;
for(i=0;i<5;i++)
{
x=5;
System.out.print(x+" ");
for(j=0;j<4;j++)
{
if(j<i)
x--;
System.out.print(x+" ");
}
System.out.println();
}
}
}
9876
ReplyDelete543
21
0
Solution of the program using BlueJ loop
ReplyDeleteimport java.io.*;
class Middle1
{
public void display()
{
int i,j,n=9;
for (i=0;i<n/2;i++)
{
for(j=i;i<n/2;i++)
{
System.out.print(n +" ");
n--;
}
System.out.println();
}
}
}
can ane1 print this pattern??
ReplyDelete7654321
66
5 5
4 4
3 3
2 2
1 1
how to print
ReplyDelete54321
4321
321
21
1
I am writing the loop statement only, no class or function.
ReplyDeletefor(i=5;i>0;i--)
{
for(j=i;j>0;j--)
{
System.out.print(j);
}
System.out.println();
}
For the pattern
ReplyDelete7654321
66
5 5
4 4
3 3
2 2
1 1
I have posted the codes on 'Program on Pattern' posted on July 30.
how to print patterns with strings like :
ReplyDeleteprogram
rogra
ogr
g
ogr
rogra
program
help please !
plz solve
ReplyDelete***********
***** *****
**** ****
*** ***
**** ****
***** *****
***********
***********
Here is the BlueJ program for the pattern:
ReplyDeleteclass BlueJ
{
public static void main(String args[])
{
BlueJ ob=new BlueJ();
ob.display();
}
public void display()
{
int x=6,y=11,flag;
for(int i=0;i< 8;i++)
{
flag=0;
for(int j= 1; j<= y; j++)
{
if(i==0 || i>=6)
System.out.print("*");
else if(j%x==0)
{
flag++;
System.out.print(" ");
}
else
System.out.print("*");
if( flag==2)
break;
}
if(i<3 && i!=0)
{
x--;
}
else if(i>=3)
{
x++;
}
System.out.println();
}
}
}
BlueJ program for the pattern as shown below:
ReplyDeleteprogram
rogra
ogr
g
ogr
rogra
program
class BlueJ
{
public static void main(String args[])
{
BlueJ ob=new BlueJ();
ob.show();
}
public void show()
{
String str="program";
int i,j,len,x,y;
len=str.length();
x=len;
y=0;
for(i= 0;i<len;i++)
{
for(j=y;j< x;j++)
{
System.out.print(str.charAt(j));
}
System.out.println();
if(i<len/2)
{
y++;
x--;
}
else
{
y--;
x++;
}
}
}
}
plzz solve
ReplyDelete1
12
123
1234
12345
plzz solv
ReplyDelete*
***
*****
*******
for the BlueJ program
ReplyDelete1
12
123
1234
12345
class BlueJ
{
public void show()
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
And For the program
*
***
*****
*******
class BlueJ
{
public void show()
{
for(int i=0;i<4;i++)
{
for(int j=0;j<i*2+1;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
plz solve fast:
ReplyDelete-1
-1-2-3
-1-2-3-4-5
plz help
ReplyDelete1
123
12345
class BlueJPatternAnother
ReplyDelete{
public void show()
{
int x=1,y;
for(int i=1;i<=3;i++)
{
y=-1;
for(int j=1;j<=x;j++)
{
System.out.print(y--);
}
x=x+2;
System.out.println();
}
}
public static void main(String args[])
{
BlueJPatternAnother ob=new BlueJPatternAnother();
ob.show();
}
}
1
ReplyDelete123
12345
class BlueJPattern
{
public void show()
{
int x=1;
for(int i=1;i<=3;i++)
{
for(int j=1;j<=x;j++)
{
System.out.print(j);
}
x=x+2;
System.out.println();
}
}
public static void main(String args[])
{
BlueJPattern ob=new BlueJPattern();
ob.show();
}
}
how to solve
ReplyDelete*
***
*****
***
*
solve this(using ASCII values):-
ReplyDeleteA
AB
ABC
ABCD
class BlueJPattern
ReplyDelete{
public void display()
{
int x=1;
int n=5;
for(int i=0;i<n;i++)
{
for(int j=0;j<x;j++)
{
System.out.print("*");
}
if(i<n/2)
x=x+2;
else
x=x-2;
System.out.println();
}
}
}
class BlueJPattern1
ReplyDelete{
public void show()
{
int x=65;
for(int i=0;i<5;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print((char)x);
x++;
}
System.out.println();
}
}
}
Ignore the 1st one . for pattern like
ReplyDeleteA
AB
ABc
this is the program
class BlueJPattern1
{
public void show()
{
int x;
for(int i=0;i<5;i++)
{
x=65;
for(int j=0;j<=i;j++)
{
System.out.print((char)x);
x++;
}
System.out.println();
}
}
}
hey can anyone solve this pattern:
ReplyDelete5 5
25 7
125 8
625 13
3125 11
15625 19
Nilotpal, here is the solution of your program.
ReplyDeleteclass BlueJPattern
{
public void show()
{
int x=5,sum,f;
for(int i=0;i<6;i++)
{
System.out.print(x+" ");
sum=0;
f=x;
while(f>0)
{
sum=sum+f%10;
f=f/10;
}
System.out.print(sum);
System.out.println();
x=x*5;
}
}
}
can you create a program with this?
ReplyDelete12345 - 12345
_1234 - 1234
__123 - 123
___12 - 12
____1 - 1
underscore means SPACE
or like this
12345
1234
123
12
1
1 0 0 0
ReplyDelete0 1 0 0
0 0 1 0
0 0 0 1
AND
1 0 0 1
0 1 1 0
0 1 1 0
1 0 0 1
For the pattern
ReplyDelete12345 - 12345
_1234 - 1234
__123 - 123
___12 - 12
____1 – 1
underscore means SPACE
BlueJ program
class BlueJPattern
{
public void show()
{
for(int i=0;i<5;i++)
{
for(int j=1;j<=i;j++)
System.out.print(" ");
for(int k=1;k<=5-i;k++)
System.out.print(k);
System.out.print(" ");
for(int m=1;m<=5-i;m++)
System.out.print(m);
System.out.println();
}
}
public static void main(String args[])
{
BlueJPattern ob=new BlueJPattern();
ob.show();
}
}
For the pattern
12345
1234
123
12
1
BlueJ program as follows:
class BlueJPattern
{
public void show()
{
for(int i=0;i<5;i++)
{
for(int k=1;k<=5-i;k++)
System.out.print(k);
if(i==4)
System.out.println();
System.out.println();
}
}
public static void main(String args[])
{
BlueJPattern ob=new BlueJPattern();
ob.show();
}
}
For the pattern
ReplyDelete1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
BlueJ program as follows:
class BlueJPattern
{
public void show()
{
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
if(i==j)
System.out.print("1");
else
System.out.print("0");
}
System.out.println();
}
}
public static void main(String args[])
{
BlueJPattern ob=new BlueJPattern();
ob.show();
}
}
For the pattern
1 0 0 1
0 1 1 0
0 1 1 0
1 0 0 1
BlueJ program as follows:
class BlueJPattern
{
public void show()
{
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
if(i==j||i+j==3)
System.out.print("1");
else
System.out.print("0");
}
System.out.println();
}
}
public static void main(String args[])
{
BlueJPattern ob=new BlueJPattern();
ob.show();
}
}
plz solve-
ReplyDelete12345678910
13579
14710
159
16
17
18
19
110
1
plz tell what does this program mean and solve it plz !!!
your programs are helping me lots...thankyou so much but pls can u help me with the logic behind the program
ReplyDelete1
12
123
1234
12345
Thank you Shweta for your complements.
ReplyDeleteWell, from the pattern it is clear that it has 5 rows. So the outer loop should run for 5 times as the rows are generated from outer loop.
In any pattern, rather in nested loops main jobs are always performed from the inner loop. So, here in this pattern the digits are printed from the inner loop. One row print means full course iteration of the inner loop. The inner loop iteration is not fixed in this pattern. The number of inner loop iteration is increased by 1 after each iteration of the outer loop (after each row). We have to set a value in the conditional statement of the inner loop which is increased by 1 after each iteration of the outer loop. The outer loop control variable is increased by one after each iteration, so set it in the conditional statement of the inner loop.
The values printed are always starting from the same value, so it the inner loop control variable value printed here as we know that in nested loop inner loop always starts from the initial value.
So the loop is as follows:
for(int i=1 ; i< 6; i++)
{
for( int j=1; j< =i; j++)
{
System.out.print(j);
}
System.out.println();
}
I think the logic is now clear to you.
plss help...i need to slve da following series:
ReplyDeletex/2!+x/4!+x/6!+....n terms
can you pls help me wid da following patern:
ReplyDelete1
333
55555
7777777
999999999
7777777
55555
333
1
can anyone pls solve this program...
ReplyDelete1
2_2
3_3_3
4_4_4_4
5_5_5_5_5
4_4_4_4
3_3_3
2_2
1
For the above three programs , please refer the post on October 3, 2010
ReplyDeleteFor the pattern
ReplyDelete12345678910
13579
14710
159
16
17
18
19
110
1
Pl. see the post of October 15
____1
ReplyDelete___21
__321
_4321
54321
I need to print out the 10th Fibonacci number only by using for loops
ReplyDeleteHere is the program to print the 10th fibonacci number
ReplyDeleteclass BlueJx
{
public void show()
{
int p=0,c=1,next=0;
for(int i=0;i<8;i++)
{
next=p+c;
p=c;
c=next;
}
System.out.println("10th element of the series="+next);
}
public static void main(String args[])
{
BlueJx ob=new BlueJx();
ob.show();
}
}
The other program is
ReplyDelete____1
___21
__321
_4321
54321
class BlueJx
{
public static void main(String args[])
{
BlueJx ob=new BlueJx();
ob.show();
}
public void show()
{
int x,i,j,k;
for(i=0;i<5;i++)
{
x=5;
for(j=i+1;j<5;j++)
{
x--;
System.out.print(" ");
}
for(k=0;k<=i;k++)
{
System.out.print(x--);
}
System.out.println();
}
}
}
1223334445555 what about that code
ReplyDelete*****
ReplyDelete* *
* *
* *
*****
pl help
class BlueJx
ReplyDelete{
public static void main(String args[])
{
BlueJx ob=new BlueJx();
ob.show();
}
public void show()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(i>0 && i<4)
{
if(j%2==0)
System.out.print("*");
else
System.out.print(" ");
if(j==2)
break;
}
else
System.out.print("*");
}
System.out.println();
}
}
}
sir..good day i wanted to know how actually the bluej system analysis and runs the programs..
ReplyDeletei will wait for your reply.....
Hi,Can you Please Show me how to Print Patterns.
ReplyDeleteI see them and Get confused and so i score poor in computer.
You send me a program on pattern, I'll clarify each statements through this blog
ReplyDeletei wanna learn the concept behind the patern printing
ReplyDeletePlease go through my post on June 6, 2010- Pattern using nested loop in BlueJ. Very soon I'll post regarding basic logics behind pattern printing.
ReplyDeleteAfter writing the codes, we compile the program. Java compiler is a software which checks the statements from top to bottom and if any syntax error is found, it reports. Ultimately compiler converts the source file in to machine code which is a .class file. Then on execution, java interpreter executes the statements.
ReplyDeletefirst print 1 to 10 with the help of arrays and then print it in 10 to 1 (opp order).
ReplyDeleteplzzzzzzzzzz solve
Here is the program can be done using do while loop
ReplyDeleteclass PPatern
{
int arr[]={1,2,3,4,5,6,7,8,9};
int i;
public void display()
{
do
{
System.out.print(" "+ arr[i]);
i++;
}while(i!=9);
i--;
System.out.println();
do
{
System.out.print(" "+ arr[i]);
i--;
}while(i>=0);
}
}
Your programs have helped me . but i really dont know the logic behind any of these patterns. can you please tell me the logic. i think i have done a big blunder for opting for computer for my class X boards. Please help me
ReplyDeletecan you please make this pattern:-
ReplyDelete1
22
333
4444
55555
also tell me the logic behind this program
This is a simple pattern, I think I have done this program in one of my previous post. Anyway here is the program
ReplyDeleteclass Pat
{
int i,j;
void show()
{
for(i=1; i< 6;i++)
{
for( j=1; j< =i;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
Please go through my recent posts in the month od December 2010 regarding basic logics behind pattern printing.
Please go through my recent posts in the month of December 2010 regarding basic logics behind pattern printing.
ReplyDelete*
ReplyDelete**
***
****
*****
Can you solve it please by tonight?
I think this type of pattern printing program is already posted in my blog. Please check the pages. Still I am again posting the program
ReplyDeleteclass A
{
int i,j;
public void display()
{
for(i=0;i< 5;i++)
{
for(j=0;j< =i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String args[])
{
A ob=new A();
ob.display();
}
}
print dis:
ReplyDelete55555
55554
55543
55432
54321
Please go through my post on 'Understading inner loop' posted on January 18,2011
ReplyDeletepls let me knw how to print this pattern
ReplyDelete1
222
33333
4444444
Here is the program
ReplyDeleteclass Pat
{
int i,n=1,j;
public void show()
{
for(i=1;i<=4;i++)
{
for(j=0;j<n;j++)
{
System.out.print(i);
}
System.out.println();
n=n+2;
}
}
public static void main(String args[])throws Exception
{
Pat obj=new Pat();
obj.show();
}
}
kind sir,u are a big help to me.thank you for your guidance.could you please post a program on merge sort and insertion sort and tell about its logic?
ReplyDeleteit will be a great help
Very soon I will post programs on these two sorting techniques. Please be in touch with this site.
ReplyDeleteMr. Admin, I just love the way you solve your programs. Straight-forward, simple and easy to follow. I'v been able to understand nested loops from your work.
ReplyDeleteI have a problem which I havent been able to solve and I was wondering if you could help me.
QUE: Using nested loops, print the following pattern -
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2 3 4 5
ReplyDelete161718196
152425207
142322218
131211109
import java.io.*;
ReplyDeleteclass smith
{
int i,j;
public void show()
{
for(i=0;i<6;i++)
{
for(j=1;j<7-i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
public static void main(String args[])throws IOException
{
smith ob=new smith();
ob.show();
}
}
how do you write a program that reads a coded message and decodes it.. the code does not exceed 200 characters ... plz help
ReplyDeleteRecently I have a program on decoding coded text. I think the program is posted on january.
ReplyDeletesir can u plz solve spiral matrix that i had posted above plzzz
ReplyDelete1 2 3 4 5
ReplyDelete16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Please refer my post on 19 February 2011
ReplyDeletecan anyone print d following pattern
ReplyDelete0
1 2
3 4 5
6 7 8 9
class Pattern
ReplyDelete{
int i,j,x=0;
public void showPattern()
{
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(x++);
}
System.out.println();
}
}
}
how to print *
ReplyDelete**
***
****
*****
can anyone solve dis pattern
ReplyDelete7777777 7777777
666666 666666
55555 55555
4444 4444
333 333
22 22
1 1
can anyone solve this pattern
ReplyDelete11111 11111
2222 2222
333 333
44 44
5 5
import java.io.*;
ReplyDeleteclass Pat
{
int i,j;
public void show()
{
for(i=7;i>0;i--)
{
for(j=0;j<i*2+1;j++)
{
if(j==i)
System.out.print(" ");
else
System.out.print(i);
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pat ob=new Pat();
ob.show();
}
}
Please remove the statement 'import java.io.*;'
ReplyDeletefor the pattern
ReplyDelete*
**
***
****
*****
Here is the loop structure
for(i=0;i<5;i++0
{
for(j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
import java.io.*;
ReplyDeleteclass Pat
{
int i,j,n=6;
public void show()
{
for(i=1;i<n;i++)
{
for(j=0;j<n*2+1-i*2;j++)
{
if(j==n-i)
System.out.print(" ");
else
System.out.print(i);
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pat ob=new Pat();
ob.show();
}
}
pls solve this for me
ReplyDelete1
121
12321
1234321
123454321
and this one
*****
****1
***21
**321
*4321
54321
respected sir...
ReplyDeletewhich programme is the toughest in blueJ from the syllabus of icse 2011.
Concentrate more on decision making programs, specially switch and else if ladder. Actually tough question can be set from any chapter.
ReplyDeleteProgram no 1:
ReplyDeleteclass Pat
{
int i,j,k,n,m=7;
/* You take the value of 'm' from user also*/
public void show()
{
for(i=0;i<m;i++)
{
n=1;
for(j=0;j<=i;j++)
{
System.out.print(n);
n++;
}
n=n-2;
for(k=0;k<i;k++)
{
System.out.print(n);
n--;
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pat ob=new Pat();
ob.show();
}
}
Program no 2:
class Pat1
{
int i,j,k,n,m=6;
public void show1()
{
for(i=0;i<m;i++)
{
n=5;
for(j=i;j<5;j++)
{
System.out.print("*");
n--;
}
for(k=0;k<i;k++)
{
System.out.print(n);
n--;
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pat1 ob=new Pat1();
ob.show1();
}
}
sir if you dont mind can i ask you how do you get the logic that you have to apply a particular logic to a particular program?sir help me in writing programs
ReplyDeleteAnalysis of a program is must to do any program. Logic development is a long term process. Whenever you get any solved program, read each and every line of codes and try to find out the logic behind the codes because behind every code there must be a logic. If you continue this process, you will be ultimately able to develop your own logic.
ReplyDeletethankyou very much sir you r very helpfl to me sir help me tu print
ReplyDelete12345
51234
45123
34512
23451
Here is the program
ReplyDeleteclass Pat
{
int i,j,n,m=100;
public void show()
{
for(i=0;i<5;i++)
{
n=1;
for(j=0;j<5;j++)
{
if(m<=5)
System.out.print(m++);
else
System.out.print(n++);
}
m=n-1;
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
im really hoping you can help me... what do i do in my for loops to do this:
ReplyDeleteoooooooooo
ooooooooo*
oooooooo**
ooooooo***
oooooo****
ooooo*****
oooo******
ooo*******
oo********
o*********
and
o*********
oo********
ooo*******
oooo******
ooooo*****
oooooo****
ooooooo***
oooooooo**
ooooooooo*
oooooooooo
For the first pattern
ReplyDeleteclass Pattern
{
int i,j,k;
public void show() throws Exception
{
for(i=0;i<10;i++)
{
for(j=0;j<10-i;j++)
System.out.print("o");
for(k=0;k<i;k++)
System.out.print("*");
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
Pattern ob=new Pattern ();
ob.show();
}
}
For the second pattern
class Pattern1
{
int i,j,k;
public void show() throws Exception
{
for(i=0;i<10;i++)
{
for(j=0;j<=i;j++)
System.out.print("o");
for(k=0;k<10-1-i;k++)
System.out.print("*");
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
Pattern1 ob=new Pattern1 ();
ob.show();
}
}
in pattern program
ReplyDelete12345
51234
45123
34512
23451
sir u hv posted why u hv taken m=100?
'm=100' is the initial value of 'm'. It can be any value greater than 5 as 'm' is getting the actual value for the first time at the end of loop body.
ReplyDeletePlease note the statements:
for(j=0;j<5;j++)
{
if(m<=5)
System.out.print(m++);
else
System.out.print(n++);
}
m=n-1;
If we do not assign any value on 'm' then it will hold default value,0 and the if statement will become true at the first time execution of the loop which is not required for the above pattern.
i would like to ask ur help 4 one of my c++ programming ques :
ReplyDeleteuse nested loops that print following patterns.
12345
1234
123
12
1
Please check cbsetutorial.blogspot.com
ReplyDeleteCan you please print
ReplyDelete123
456
789
?
Thank you!
I am simply function to print the pattern.
ReplyDeletevoid show()
{
int i,j,x=1;
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
System.out.print(x++);
}
System.out.println();
}
}
Sir i need a program for the following pattern :
ReplyDelete1
12
123
1234
123
12
1
Sir,
ReplyDeletecan you please post a program to print cubes of 20 natural numbers skipping numbers that are divisible by 2 and 3.
class Post
ReplyDelete{
int i;
public void show()
{
for(i=1;i< =20;i++)
{
if(i%2!=0 && i%3!=0)
System.out.print(" "+ (i*i*i));
}
}
public static void main(String args[])
{
Post ob=new Post();
ob.show();
}
}
class Post
ReplyDelete{
int i,j,x=1;
public void show()
{
for(i=0;i< 7;i++)
{
if(i >7/2)
x--;
else
x++;
for(j=1;j< x;j++)
{
System.out.print(j);
}
System.out.println();
}
}
public static void main(String args[])
{
Post ob=new Post();
ob.show();
}
}
Thank you Sir...!!
ReplyDeleteDisplay the pattern:- 1
ReplyDelete121
12321
1234321
123454321
1234321
12321
121
1
can you please help me display this pattern:
ReplyDeleteaaaaa
bbbb
ccc
dd
e
dd
ccc
bbbb
aaaaa
Search my blog, similar programs are posted
ReplyDeleteclass Pat
ReplyDelete{
int i,j,k,x,y;
public void show()
{
for(i=0; i<9;i++)
{
x=1;
if(i<5)
y=i;
else
y=y-1;
for(j=0;j<=y;j++)
{
System.out.print(x++);
}
x=x-2;
for(k=0;k<y;k++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void main(String args[])
{
Pat b=new Pat();
b.show();
}
}
class Pat
ReplyDelete{
int i,j,x=5;
char ch='a';
public void show()
{
for(i=0; i<9;i++)
{
for(j=0;j<x;j++)
{
System.out.print(ch);
}
if(i<4)
{
ch++;
x--;
}
else
{
ch--;
x++;
}
System.out.println();
}
}
public static void main(String args[])
{
Pat b=new Pat();
b.show();
}
}
Sir,
ReplyDeleteI need a program for the following patterns:
(1)54321
5432
543
54
5
(2)5
54
543
5432
54321
For pattern :
ReplyDelete54321
5432
543
54
5
class Pat
{
int i,j;
public void show()
{
for(i=5;i>=1;i--)
{
for(j=5;j>5-i;j--)
{
System.out.print(j);
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
For pattern:
5
54
543
5432
54321
class Pat
{
int i,j,x=1;
public void show()
{
for(i=5;i>=1;i--)
{
for(j=0;j<x;j++)
{
System.out.print((5-j));
}
x++;
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Thank you Sir..!!
ReplyDeletei want to print this pattern...how to do it?
ReplyDelete11111
22222
33333
44444
55555
class Pattern
ReplyDelete{
int i,j;
public void show()
{
for(i=1;i < = 5;i++)
{
for(j=1; j < =5;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
plz help me wid this program:
ReplyDelete1
212
32123
4321234
sir,plzz can you solve this pattern:
ReplyDeleteL
L O
L O T
L O T U
L O T U S
L O T U
L O T
L O
L
class Lotus
ReplyDelete{
int i,j,len,x,flag=0;
String str="LOTUS";
void show()
{
len=str.length();
x=0;
for(i=0;i<len*2-1;i++)
{
if(x==len)
flag=1;
if(flag==0)
x++;
else
x--;
for(j=0;j<x;j++)
{
System.out.print(str.charAt(j));
}
System.out.println();
}
}
public static void main(String args[])
{
Lotus ob=new Lotus();
ob.show();
}
}
class Pat1
ReplyDelete{
int i,j,k,x;
void show()
{
for(i=0;i<4;i++)
{
x=i+1;
for(j=0;j<=i;j++)
{
System.out.print(x--);
}
x=x+2;
for(k=0;k<i;k++)
{
System.out.print(x++);
}
System.out.println();
}
}
public static void main(String args[])
{
Pat1 ob=new Pat1();
ob.show();
}
}
can u help me in printing these......??
ReplyDeletea)
****
***
**
*
b)
*
**
***
****
c)
*
***
*****
*******
The three programs are given below:
ReplyDeletepublic class Pattern1
{
int i,j;
void show()
{
for(i=0;i<4;i++)
{
for(j=i;j<4;j++)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern1 ob=new Pattern1 ();
ob.show();
}
}
public class Pattern2
{
int i,j;
void show()
{
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern2 ob=new Pattern2 ();
ob.show();
}
}
public class Pattern3
{
int i,j,x=1;
void show()
{
for(i=0;i<4;i++)
{
for(j=0;j<x;j++)
{
System.out.print("*");
}
x=x+2;
System.out.println();
}
}
public static void main(String args[])
{
Pattern3 ob=new Pattern3 ();
ob.show();
}
}
please solve the pattern
ReplyDeleteB
L
B L U E J
E
J
how to do pattern
ReplyDelete1. 1AAAA
22BBB
333CC
4444D
55555
2. 1
232
34543
4567654
3. 1
01
101
0101
10101
4. a
ab
abc
abcd
abcde
Plz reply fast
class Pat
ReplyDelete{
String str="BLUEJ";
int i,j;
void disp()
{
int len=str.length();
for(i=0;i<len;i++)
{
if(i==len/2)
{
for(j=0;j<len;j++)
System.out.print(str.charAt(j));
}
else
{
for(j=i;j<=i;j++)
System.out.print(str.charAt(j));
}
System.out.println();
}
}
}
Here are the programs:
ReplyDeleteclass Pattern
{
public void disp()
{
int i,j,k;
for(i=1;i< =5;i++)
{
for(j=1;j< =i;j++)
{
System.out.print(i);
}
for(k=i;k< 5;k++)
{
System.out.print((char)(i+64));
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.disp();
}
}
1
232
34543
4567654
class Pattern
{
public void disp()
{
int i,j,k,x;
for(i=0;i< 4;i++)
{
x=i+1;
for(j=0;j< =i;j++)
{
System.out.print(x++);
}
x=x-2;
for(k=0;k< i;k++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.disp();
}
}
1
01
101
0101
10101
class Pattern
{
public void disp()
{
int i,j;
for(i=0;i< 5;i++)
{
for(j=0;j< =i;j++)
{
if((i%2==0 && j%2==0)||(i%2!=0 && j%2!=0))
System.out.print("1");
else
System.out.print("0");
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.disp();
}
}
a
ab
abc
abcd
abcde
class Pattern
{
public void disp()
{
int i,j,x;
for(i=0;i< 5;i++)
{
x=97;
for(j=0;j< =i;j++)
{
System.out.print((char)(x+j));
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.disp();
}
}
Please solve:
ReplyDelete2
5 10
17 26 37
class A
ReplyDelete{
int i,j,x=2,y=3;
public void show()
{
for(i=0;i<3;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(x+ " ");
x=x+y;
y=y+2;
}
System.out.println();
}
}
}
please solve the following pattern
ReplyDeletec
o o
m m m
p p p p
u u u u u
t t t t t t
e e e e e e e
r r r r r r r r
C
ReplyDeleteO O
M M M
P P P P
U U U U U
T T T T T T
E E E E E E E
R R R R R R R R
Sir can you solve this program:-
ReplyDelete5555
4444
3333
2222
1111
sir can you plzz print the folloing programs:
ReplyDeletea) 1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
b)
1
121
12312
1234123
c)
1
121
12312
1234123
12321
121
1
class Pat
ReplyDelete{
int i,j;
public void dis()
{
for(i=5;i >0;i--)
{
for(j=0;j< 5;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
class Comp
ReplyDelete{
String str="COMPUTER";
int i,j,len;
public void show()
{
len=str.length();
for(i=0;i< len;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(str.charAt(i));
}
System.out.println();
}
}
}
class Comp
ReplyDelete{
String str="computer";
int i,j,len;
public void show()
{
len=str.length();
for(i=0;i< len;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(str.charAt(i));
}
System.out.println();
}
}
}
Programs of the programs (a),(b) and (c) are :
ReplyDelete2nd program
a) public class Bubblesort
b) {
c) int i,j,k,x;
d) public void show()
e) {
f) for(i=0;i<4;i++)
g) {
h) x=1;
i) for(j=0;j<=i;j++)
j) {
k) System.out.print(x);
l) x++;
m) }
n) x=1;
o) for(k=0;k=7/2)
f=1;
if(f==1)
n--;
else
n++;
System.out.println();
}
}
}
2nd program
ReplyDeletepublic class Bubblesort
{
int i,j,k,x;
public void show()
{
for(i=0;i<4;i++)
{
x=1;
for(j=0;j<=i;j++)
{
System.out.print(x);
x++;
}
x=1;
for(k=0;k<i;k++)
{
System.out.print(x);
x++;
}
System.out.println();
}
}
}
1st program
ReplyDeletepublic class Bubblesort
{
int i,j,x=1;
public void show()
{
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(x);
x++;
}
System.out.println();
}
}
3rd program
public class Bubblesort
{
int i,j,x,k,n=0,f=0;
public void show()
{
for(i=0;i<7;i++)
{
x=1;
for(j=0;j<=n;j++)
{
System.out.print(x);
x++;
}
x=1;
for(k=0;k=7/2)
f=1;
I need hellp with this program -
ReplyDeleteWAP to input a number and print the sum of first and last digits of that number.
Sir can you please help me with this pattern i will be grateful......
ReplyDelete*****
****
***
**
*
import java.io.*;
ReplyDeletepublic class Bubblesort
{
int s=0,a,b,len;
String str;
char ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void show()throws Exception
{
System.out.println("Enter the number:");
str=br.readLine();
len=str.length();
ch=str.charAt(0);
a=ch-48;
ch=str.charAt(len-1);
b=ch-48;
a=a+b;
System.out.println("Sum="+a);
}
}
For all the programs a lot of thanks!!!!
ReplyDeleteclass A
ReplyDelete{
int i,j;
public void show()
{
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
{
System.out.print("*");
}
System.out.println()'
}
}
}
C
ReplyDeleteOO
MMM
PPPP
UUUUU
TTTTTT
EEEEEEE
RRRRRRRR
SIR, KINDLY PLS TELL ME HOW TO PRINT THIS PATTERN
I think few days back, I have posted similar program.
ReplyDeleteclass Pat
{
String str;
int i,j,len;
str="COMPUTER";
public void showPattern()
{
len=str.length();
for(i=0;i<len;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(str.charAt(i));
}
System.out.println();
}
}
}
1234554321
ReplyDelete1234 4321
123 321
12 21
1 1
12 21
123 321
1234 4321
1234554321
sir please help me out... i beg your pardon
*
ReplyDelete* *
* *
* *
* *
* *
*
please sir solve this one.... i beg your pardon...
Please check this one:
ReplyDeletepublic class Pattern
{
int i,j,k,x,y=5;
public void show()
{
for(i=0;i< 9;i++)
{
x=1;
for(j=0;j< y;j++)
System.out.print(x++);
if(i!=0 && i!=8)
{
for(j=0;j< 1;j++)
System.out.print(" ");
}
x=x-1;
for(k=0;k< y;k++)
System.out.print(x--);
System.out.println();
if(i>=9/2)
y++;
else
y--;
}
}
public static void main(String args[])throws Exception
{
Pattern ob=new Pattern ();
ob.show();
}
}
"-" SPACE.. FOR INDICATION AS SPACE IS NOT TAKEN
ReplyDeleteBY THIS BOXX....
----*
---*-*
--*---*
-*-----*
--*---*
---*-*
----*
plese sir make this one out...
"-" SPACE.. FOR INDICATION AS SPACE IS NOT TAKEN
ReplyDeleteBY THIS BOXX....
----a
---aba
--abcba
-abcdcba
abcdedcba
-abcdcba
--abcba
---aba
----a
plese solve the above 3 recent programs posted by me... i beg your pardon..
public class Series
ReplyDelete{
int i,m,n,k,a=0,b=0;
char x;
public void show()
{
for(i=0;i<9;i++)
{
x='a';
for(k=a;k<4;k++)
System.out.print(" ");
for(m=0;m<=b;m++)
{
System.out.print(x);
x=(char)(x+1);
}
x=(char)(x-2);
for(n=0;n<b;n++)
{
System.out.print(x);
x=(char)(x-1);
}
System.out.println();
if(i<9/2)
{
a++;
b++;
}
else
{
a--;
b--;
}
}
}
public static void main(String args[]) throws Exception
{
Series ob=new Series();
ob.show();
}
}
*********
ReplyDelete**** ****
*** ***
** **
* *
** **
*** ***
**** ****
*********
public class Pattern
ReplyDelete{
int i,j,k,y=5;
public void show()
{
for(i=0;i< 9;i++)
{
for(j=0;j< y;j++)
System.out.print("*");
if(i!=0 && i!=8)
{
for(j=0;j< 1;j++)
System.out.print(" ");
}
for(k=0;k< y;k++)
System.out.print("*");
System.out.println();
if(i>=9/2)
y++;
else
y--;
}
}
public static void main(String args[])throws Exception
{
Pattern ob=new Pattern ();
ob.show();
}
}
a sincere thanks a lot for all the programs///
ReplyDeleteplease please do this program////.. "-"-space
----*
---*-*
--*---*
-*-----*
--*---*
---*-*
----*
public class Series
ReplyDelete{
int i,j,k,y=1,x=4,m,n;
public void show()
{
for(i=0;i<7;i++)
{
for(k=0;k<x;k++)
System.out.print(" ");
for(n=0;n<y;n++)
{
if(n==0 || n==y-1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
if(i<7/2)
{
x--;
y=y+2;
}
else
{
x++;
y=y-2;
}
}
}
public static void main(String args[]) throws Exception
{
Series ob=new Series();
ob.show();
}
}
12345 54321
ReplyDelete1234 4321
123 321
12 21
1 1
12 21
123 321
1234 4321
12345 54321
sir plz give a solution
Already posted, still posting for the second time
Deleteimport java.io.*;
class Arr
{
int i,j,x,y=1,k,m,n;
public void show()
{
m=5;
for (i=0;i<9;i++)
{
x=1;
for(j=0;j<m;j++)
System.out.print(x++);
for(k=0;k<y;k++)
System.out.print(" ");
x--;
for(j=0;j<m;j++)
System.out.print(x--);
System.out.println();
if(i<9/2)
{
m--;
}
else
{
m++;
}
}
}
}
1234554321
ReplyDelete1234---4321
123------321
12---------21
1------------1
12---------21
123------321
1234---4321
1234554321
"-" this is for space
Already posted, still posting for the second time
Deleteimport java.io.*;
class Arr
{
int i,j,x,y=0,k,m,n;
public void show()
{
m=5;
for (i=0;i<9;i++)
{
x=1;
for(j=0;j<m;j++)
System.out.print(x++);
for(k=0;k<y;k++)
System.out.print(" ");
x--;
for(j=0;j<m;j++)
System.out.print(x--);
System.out.println();
if(i<9/2)
{
m--;
y=y+3;
}
else
{
m++;
y=y-3;
}
}
}
}
1234554321
ReplyDelete1234---4321
123------321
12---------21
1------------1
12---------21
123------321
1234---4321
1234554321
import java.io.*;
ReplyDeleteclass Arr
{
int i,j,x,y=0,k,m,n;
public void show()
{
m=5;
for (i=0;i<9;i++)
{
x=1;
for(j=0;j<m;j++)
System.out.print(x++);
for(k=0;k<y;k++)
System.out.print(" ");
x--;
for(j=0;j<m;j++)
System.out.print(x--);
System.out.println();
if(i<9/2)
{
m--;
y=y+3;
}
else
{
m++;
y=y-3;
}
}
}
}
*****
ReplyDelete* *
* *
* *
*****
cn u tell me the java code abt this pattern.
class border
Delete{
int i,j,x=6;
public void show()
{
for(i=0;i<5;i++)
{
for(j=0;j<x;j++)
{
if(x==3 && j%2==0)
System.out.print("*");
else if(x==3 && j%2!=0)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
if(i==3)
x=6;
else
x=3;
}
}
}
sir can you Plzz solve
ReplyDelete-----*
----***
---*****
--*******
-*********
***********
class border
ReplyDelete{
int i,j,k,x=1;
public void show()
{
for(i=0;i<6;i++)
{
for(j=i;j<5;j++)
System.out.print(" ");
for(k=0;k<x;k++)
System.out.print("*");
System.out.println();
x=x+2;
}
}
}
B
ReplyDeleteBL
BLU
BLUE
BLUEJ
class Arr
ReplyDelete{
int i,j,x;
String str="BLUEJ";
public void show()
{
x=str.length();
for (i=0;i<x;i++)
{
for(j=0;j<=i;j++)
System.out.print(str.charAt(j));
System.out.println();
}
}
}
sir all of ur posts have been a great help to me thank u soooo much.sir i kindly request u to post the logic for the following pattern
ReplyDelete1234321
23432
343
4
343
23432
1234321
sir i request u 2 post this as soon as possible.thank u.
Please check my today's post
Deletesir this is chaitanya itself no time to sign up since my internet connec is slow.respected sir i could not find your yesterday's post.plz tel me hw i can find it,sorry coz i'm new 2 ur site.
DeleteI think I have done some mistake. Ok, I am again posting the program:
Deleteclass Arr
{
int i,j,x,a=0,y=7;
public void show()
{
for(i=0;i<7;i++)
{
if(i<=7/2)
a++;
else
a--;
x=a;
for(j=0;j<y;j++)
{
if(j<y/2)
System.out.print(x++);
else
System.out.print(x--);
}
if(i<7/2)
y=y-2;
else
y=y+2;
System.out.println();
}
}
}
sir can you also post the code for the following
Delete*___________*
___*_______*_
_____*___*_
_______*____
_____*___*__
___*_______*
*____________*
sir,plz give a bit of explanation since i just donot have any idea abt the program.
1
ReplyDelete23
456
78910
1112131415
please sir..
class A
Delete{
int i,j,x=1;
void show()
{
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(x++);
}
System.out.println();
}
}
}
Thanks Sir!
Deletea program for this pattern plz
ReplyDelete123456789
2345678
34567
456
5
456
34567
2345678
123456789
Please visit this page
Deletehow to print that the no. entered is ARMSTRONG NUMBER or not..plzz tell fast Sir..
ReplyDeleteSearch in by blog, you will get the program.
DeleteI want this bluej program for the following pattern -
ReplyDeletea
a b
a b c
a b c d
import java.io.*;
Deleteclass Pattern
{
int i,j;
char ch;
void show()
{
for(i=0;i<4;i++)
{
ch='a';
for(j=0;j<=i;j++)
{
System.out.print(ch+" ");
ch=(char)(ch+1);
}
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.show();
}
}
I want bluej program for the following pattern -
ReplyDelete---a
--a b
-a b c
a b c d
these - are blank spaces to be left , you need not to print these -s.
class Merging
Delete{
void show()
{
int i,j,k,x=1;
char ch;
for(i=0;i<4;i++)
{
ch='a';
for(k=i;k<3;k++)
System.out.print(" ");
for(j=0;j<x;j++)
{
if(j%2==0)
{
System.out.print(ch);
ch=(char)(ch+1);
}
else
System.out.print(" ");
}
x=x+2;
System.out.println();
}
}
}
wap to find the sum of all the elements which lie on either diagonal.
ReplyDeletePlease check this page
Deletewap to print pattern
ReplyDelete*
**
***
****
*****
class Merging
Delete{
void show()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
i know its not pattern but please do it.
ReplyDelete* wap to input a string and print out the text with the upper case and lower case letters reversed but all the characters should remain the same as before.
eg;-Welcome TO School
wELCOME to sCHOOL
please do it many people want this program.
class Pattern
Delete{
void show(String str)
{
int i,len;
len=str.length();
for(i=0;i=65 && str.charAt(i)<=97)
System.out.print((char)(str.charAt(i)+32));
else if(str.charAt(i)>=97 && str.charAt(i)<=122)
System.out.print((char)(str.charAt(i)-32));
else
System.out.print(str.charAt(i));
}
}
}
do this one
ReplyDelete----a
---a b
--a b c
-a b c d
class Pattern
Delete{
void show()
{
int i,j,k;
char ch;
for(i=0;i<4;i++)
{
ch='a';
for(j=i;j<4;j++)
System.out.print(" ");
for(k=0;k<=i;k++)
{
System.out.print(ch+" ");
ch=(char)(ch+1);
}
System.out.println();
}
}
}
how to print pattern
ReplyDelete54321
5432
543
54
5
class Pattern
Delete{
void show()
{
int i,j,x;
for(i=0;i<5;i++)
{
x=5;
for(j=i;j<5;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pattern ob=new Pattern();
ob.show();
}
}
plz sir solve this question
Delete1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
* * * * *
ReplyDelete* *
* *
* *
* * * * *
how would I print this one?
thanks
can you please solve
ReplyDelete*
***
*****
but the triangle has a variable N, and N is the number of stars at the bottom line.
You can assume that N will always be an odd number with a minimum value of 3.
for example
N=3
*
***
N=5
*
***
*****
N=7
*
***
*****
*******
class Pat
Delete{
int i,j,x=1;
public void show(int n)
{
for(i=0;i<n;i++)
{
for(j=0;j<x;j++)
{
System.out.print("*");
}
x=x+2;
System.out.println();
}
}
}
class Pat
Delete{
int i,j,x=1;
public void show()
{
for(i=0;i<3;i++)
{
for(j=0;j<x;j++)
{
System.out.print("*");
}
x=x+2;
System.out.println();
}
}
}
please sir solve a question
ReplyDelete1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
wap to print -
ReplyDelete123456789
12345678
1234567
123456
12345
1234
123
12
1
class Pat
Delete{
int i,j,x;
public void show(int n)
{
for(i=0;i<n;i++)
{
x=1;
for(j=i;j<n;j++)
{
System.out.print(x++);
}
System.out.println();
}
}
}
Sir, please help me out with the following pattern program..... urgent..
ReplyDelete*
* *
* *
* *
* *
* *
*