Question 19 : Write a program in Java to print the following pattern :
55555
4444
333
22
1
55555
4444
333
22
1
Java Program :
public class pattern_6
{
public static void main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.print("\n");
}
}
}
Can you write a program to print this series please?
ReplyDelete*****1
****121
***12321
**1234321
***12321
****121
*****1
The stars are actually blanks.
import java.io.*;
ReplyDeletepublic class M25
{
public void main()throws IOException
{
int r,c,s,sp,a;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br =new BufferedReader(in);
System.out.println("How many rows do you want?");
a=Integer.parseInt(br.readLine());
sp=2*a;
for(r=1;r<=a;r++)
{
for (s=1;s<=sp;s++)
System.out.print(" ");
for (c=1;c<=r;c++)
System.out.print(c+" ");
sp=sp-2;
for(c=r-1;c>=1;c--)
System.out.print(c+" ");
System.out.println();
}
for(r=a-1;r>=1;r--)
{
for (s=1;s<=sp+4;s++)
System.out.print(" ");
for (c=1;c<=r;c++)
System.out.print(c+" ");
sp=sp+2;
for(c=r-1;c>=1;c--)
System.out.print(c+" ");
System.out.println();
}
}
}
write the program for the following output
ReplyDeletearr={444,55555,7777,666,22,11}
output: arr={5555,7777,444,666,11,22};
write the program for the following output
ReplyDelete1
3*2
4*5*6
10*9*8*7
this is the program output range was n;
1234321
ReplyDelete123*321
12***21
1*****1