Define a class to accept values into a 3x3 integer array and print the product of each row elements.

ICSE Class 10 Computer Applications PYQ · 2025 Improvement · Section B

4Written · 2025 · Section B · 2025 Improvement

Define a class to accept values into a 3x3 integer array and print the product of each row elements.

Example:

312
421
512

Output:

Row 0 – 6
Row 1 – 8
Row 2 – 10

Show SolutionHide Solution↓
import java.util.Scanner;

public class RowProduct {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] arr = new int[3][3];

        System.out.println("Enter 9 integers for the 3x3 array:");
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < 3; i++) {
            int product = 1;
            for (int j = 0; j < 3; j++) {
                product *= arr[i][j];
            }
            System.out.println("Row " + i + " – " + product);
        }
    }
}
BlueJ output of RowProduct.java
← Previous questionNext question →

Browse the free Computer Applications sample bank