◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆
Plz help me with this problem
Print a pattern in the Java program....
1
12
123
1234
123
12
1
◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆
Answers
Answered by
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(" ");
}
}
}
{
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
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!
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!☺️
Similar questions
Math,
7 months ago
Math,
7 months ago
Math,
7 months ago
Math,
1 year ago
Political Science,
1 year ago