write a program to print following pattern
Attachments:
Anonymous:
through java?
Answers
Answered by
13
Sample Java Program to print pattern:
import java.util.*;
class brainly
{
public static void main(String args[])
{
int i,j,k,num;
Scanner demo = new Scanner(System.in);
System.out.println("Enter the number of rows: ");
num = demo.nextInt();
for(i = 0; i <=num; i++)
{
for(j=1;j<=num-i;j++)
System.out.print(" ");
for(j = 1; j<=i;j++)
System.out.print(j);
for(j=i-1;j>=1;j--)
System.out.print(j);
System.out.println();
}
}
Output:
Enter the number of rows: 4
1
121
12321
1234321
Hope it helps!
Attachments:
Similar questions