Multiplication based on input integer and return array- Need help in storing array while looping

Try this

System.out.println("Enter number of entries");
        Scanner scan = new Scanner (System.in);
        int i,j,k,index=0;
        int value = scan.nextInt();
        int totalSize= value * value ;
        int [] a= new int [totalSize];

        for(i=1; i<=value;i++) {
            for (j = 1; j <= value; j++) {
                a[index++] = i * j;
            }
        }
        for(k=0; k<totalSize;k++) {
            System.out.println(a[k]);
        }

Browse More Popular Posts

Leave a Comment