In Java, Write a program to store 20 numbers in an array then display those numbers in one column and the digits in another column with comma within the digits as follows:
2345 2,3,4,5
260 2,6,0
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int[] arr={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
for(int i=0;i<20;i++){
System.out.print(arr[i]);
}
for(int j=0;j<20;j++){
System.out.print(" "+arr[j]+",");
}
}
}
Comments
Leave a comment