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
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
Biology,
6 months ago
Computer Science,
6 months ago
Chemistry,
1 year ago
Physics,
1 year ago
Economy,
1 year ago