Report

Share

•0 likes•2 views

Write a program that takes an input of n and prints the numbers from 1 to n ( for n lines): Solution MainProgram.java import java.util.Scanner; public class MainProgram { public static void main(String[] args){ int s=1; Scanner in=new Scanner(System.in); System.out.println(\"Enter your number elements: \"); int n=in.nextInt(); while(s<=n) {for(int i=1; i<=n; i++){ System.out.print(i); } System.out.println(); s++; } }} Output : Enter your number elements: 6 123456 123456 123456 123456 123456 123456 .

•0 likes•2 views

Report

Share

Write a program that takes an input of n and prints the numbers from 1 to n ( for n lines): Solution MainProgram.java import java.util.Scanner; public class MainProgram { public static void main(String[] args){ int s=1; Scanner in=new Scanner(System.in); System.out.println(\"Enter your number elements: \"); int n=in.nextInt(); while(s<=n) {for(int i=1; i<=n; i++){ System.out.print(i); } System.out.println(); s++; } }} Output : Enter your number elements: 6 123456 123456 123456 123456 123456 123456 .

- 1. Write a program that takes an input of n and prints the numbers from 1 to n ( for n lines): Solution MainProgram.java import java.util.Scanner; public class MainProgram { public static void main(String[] args){ int s=1; Scanner in=new Scanner(System.in); System.out.println("Enter your number elements: "); int n=in.nextInt(); while(s<=n) {for(int i=1; i<=n; i++){ System.out.print(i); } System.out.println(); s++; } }} Output : Enter your number elements: 6 123456 123456 123456 123456 123456 123456