Monday, August 15, 2016

// // Leave a Comment

Multiplication Table Program In Java Using Array

This is a simple Java program to produce a 12x12 multiplication table using 2-dimensional array.

/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 */ 

public class ArrayMultiplicationTable {

    public static void main(String[] args) {
        int[][] demo = new int[12][12];
        int row = 1, column = 1;
        for (int x = 0; x < demo.length; x++) {
            for (int y = 0; y < demo[x].length; y++) {
                demo[x][y] = row * column;
                column = column + 1;
            }
            row = row + 1;
            column = 1;
        }
        for (int x = 0; x < demo.length; x++) {
            for (int y = 0; y < demo[x].length; y++) {
                System.out.print("  " + demo[x][y] + "\t|");
            }
            System.out.println();
        }
    }
}

See program output below

Java Multiplication Table Output
Program output

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.