[Question 10] ISC 2013 (Theory) Paper Solved

Question:

A class Matrix contains a two dimensional integer array of order [m x n]. The maximum value possible for both ‘m’ and ‘n’ is 25. Design a class Matrix to find the difference of the matrices. The details of the members of the class are given below:

Class name : Matrix

Data members/instance variables:
arr[ ][ ] : stores the matrix element
m : integer to store the number of rows
n : integer to store the number of columns

Member functions:
Matrix(int mm, int nn) : to initialize the size of the matrix m = mm and n = nn
void fillarray() : to enter the elements of the matrix
Matrix SubMat(Matrix A) : subtract the current object from the matrix of parameterized object and return the resulting object
void display() : display the matrix elements

Specify the class Matrix giving details of the constructor(int,int), void fillarray(), Matrix SubMat(Matrix A) and void display(). Define the main() function to create objects and call the function accordingly to enable the task.

Programming Code:

Output:

Enter the number of Rows: 2
Enter the number of Columns: 3

Enter the 1st Matrix
Enter Element at [0][0] : 15
Enter Element at [0][1] : 2
Enter Element at [0][2] : 4
Enter Element at [1][0] : 53
Enter Element at [1][1] : 19
Enter Element at [1][2] : 37

Enter the 2nd Matrix
Enter Element at [0][0] : 11
Enter Element at [0][1] : 50
Enter Element at [0][2] : 3
Enter Element at [1][0] : 9
Enter Element at [1][1] : 45
Enter Element at [1][2] : 8

The 1st Matrix
15 2 4
53 19 37

The 2nd Matrix
11 50 3
9 45 8

The Resultant Matrix
-4 48 -1
-44 26 -29

A teacher whose aim is to make Java a fun to learn experience for the school students by striving to build clear fundamentals of every concepts and helping students to develop their ability to reason and logically analyze any given programs.

Your Turn To Talk

Your email address will not be published.