Write a program to display the following output
1
1 1
1 1 1
import java.util.Scanner; public class NumberGenerator { public static void main(String[] args) { int i,j; System.out.println("ENTER THE NUMBER TO BE DISPLAYED :-"); Scanner sc=new Scanner(System.in); int a=sc.nextInt(); System.out.println("ENTER THE SIZE :-"); int n=sc.nextInt(); for(i=0;i<n;i++) { for(j=0;j<=i;j++) System.out.print(" "+a); System.out.println(); } }
No comments:
Post a Comment