Write a program to display numbers order in pyramid pattern
package com.test.javahit; import java.util.Scanner; public class ForLoop2 { public static void main(String[] args) { System.out.println("Enter the limit:-"); Scanner sc=new Scanner(System.in); int limit=sc.nextInt(); for(int i=1;i<=limit;i++) { for(int j=1;j<=i;j++) { System.out.print( j +" "); } System.out.println(); } } } Enter the limit:- 5 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
No comments:
Post a Comment