0% found this document useful (0 votes)
32 views2 pages

2D Array Practice Problems

The document outlines a series of programming problems focused on 2D arrays, including tasks such as displaying arrays in a tabular format, calculating sums and averages, checking for transpose and identity matrices, and determining if a matrix is sparse or dense. Additional problems involve calculating determinants, performing statistical analysis for student quiz scores, and simulating a game that matches tables. Each problem is designed to enhance understanding and manipulation of 2D arrays in programming.

Uploaded by

stv00998877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

2D Array Practice Problems

The document outlines a series of programming problems focused on 2D arrays, including tasks such as displaying arrays in a tabular format, calculating sums and averages, checking for transpose and identity matrices, and determining if a matrix is sparse or dense. Additional problems involve calculating determinants, performing statistical analysis for student quiz scores, and simulating a game that matches tables. Each problem is designed to enhance understanding and manipulation of 2D arrays in programming.

Uploaded by

stv00998877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

2D Array Practice Problems

1. Write a program to input a 2D array of size MxN (M rows and N columns) and display it
in a tabular format, where each element is printed in a grid-like structure with proper
alignment.
2. Write a program to input a 2D array of size MxN and calculate the sum and average of all
its elements. Print both the sum and the average as the output. For example, if the matrix
is [[1, 2], [3, 4]], the sum would be 10 and the average would be 2.5.
3. Write a program to input a 2D array of size MxN and display the sum of each row and each
column separately. For example, for the matrix [[1, 2], [3, 4]], the row sums would be [3,
7] and the column sums would be [4, 6].
4. Write a program to check whether a given 2D array is a transpose matrix. A matrix is said
to be a transpose of itself if element at position [i][j] is the same as the element at position
[j][i]. For example, the matrix [[1, 2], [2, 1]] is its own transpose, while [[1, 2], [3, 4]] is
not.
5. Write a program to input a square matrix and check whether it is an identity matrix or not.
An identity matrix has 1s on the diagonal from the top-left to bottom-right and 0s
elsewhere. For example,
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]] is an identity matrix.
6. Write a program to input a matrix of order MxN and check if it is a sparse matrix or a dense
matrix. A sparse matrix has most of its elements as zero (generally more than half), whereas
a dense matrix has most elements as non-zero. Print whether the matrix is sparse or dense.
7. Write a program to check whether a square matrix is a lower triangular matrix or not. A
lower triangular matrix is a square matrix where all elements above the main diagonal are
zero. Example: The matrix
[[1, 0, 0],
[2, 3, 0],
[4, 5, 6]] is a lower triangular matrix, while
[[1, 2, 0],
[0, 3, 4],
[0, 0, 6]] is not.
8. Write a program in C to calculate the determinant of a 3x3 matrix using standard
determinant formula. For example, the determinant of matrix
[[a, b, c],
[d, e, f],
[g, h, i]] is calculated as a(ei − fh) − b(di − fg) + c(dh − eg).
9. Write a program to keep records and perform statistical analysis for a class of up to 10
students. Each student will have three quiz scores and be identified by a unique four-digit
roll number. The program should print the quiz scores of each student and perform the
following tasks:
a) Print the highest and lowest score for each quiz along with the roll number of the
respective students.
b) Calculate and display the average score for each quiz and the overall average of all
quizzes.
c) Identify the quiz with the highest and lowest average scores.
d) Print the highest and lowest marks of each student along with the quiz number.
10. Suppose there is a game called "MATCH THE TABLES" where the player picks two
tables, each with 10 rows and 10 columns, and tries to match them. If at least 90
corresponding entries out of the total 100 match between the two tables, the tables are
considered identical, and the player is declared the winner. Write a program to simulate
this game and determine whether the player wins or not.

You might also like