Computer Science, asked by vijay00771, 1 year ago

write program in java to displaythe following pattern

1
2 3
3 4 5
4 5 6 7
5 6 7 8 9

Answers

Answered by Anonymous
0

Answer:

import java.util.*;

public class Asn4{

public static void main(String[] args){

Scanner bob=new Scanner(System.in);

System.out.print("Enter a number: ");

int c=bob.nextInt();

System.out.print("Enter a character: ");

String d=bob.next();

bob.close();

F5(c, d);

}

public static void F5(int c, String d){

for (int i=0; i<c;i++){

for (int f=0; f<=c-i; f++){

System.out.print(" ");

}

for (int x=1; x<=1+2*i; x++){

System.out.print(d);

}

System.out.println("");

}

}

}

Similar questions