Computer Science, asked by Samanwita, 1 year ago

◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

Plz help me with this problem

Print a pattern in the Java program....

1
12
123
1234
123
12
1

◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

Answers

Answered by mathlovernishant
3
class p
{
public static void main ()
{
for(int i =1; i<=4; i++)
{
for(int j=1; j<=i; j++)
System.out.print(j);
System.out.println(" ");
}
for(int k=3; k>=1; k--)
{
for(int l=1; l<=k; l++)
System.out.print(k);
System.out.println(" ");
}
}
}
Answered by siddhartharao77
6
import java.util.*
Class Brainly
{
public static void main(String[] args)
{
int i,j,num;

System.out.println("Enter the length: ");
Scanner demo=new Scanner(System.in);
num = demo.nextInt();

for(i = 1;i<=num;i++)
{
for(j=1;j<=i;j++)
{
System.out.println(j);
}
System.out.println("\n");
}
for(i = num-1;i >= 1; i--)
{
for(j = 1;j<=i;j++)
{
System.out.println(j);
}
System.out.println("\n");
}
}
}


Hope this helps!
Attachments:

Samanwita: Thnx bro!☺️
mathlovernishant: it's all right
Similar questions