100% found this document useful (1 vote)
2K views2 pages

2D Array Practice Questions

This document contains 21 practice questions related to 2D arrays in C programming. The questions cover a range of topics including inputting and displaying 2D arrays, calculating sums and averages of elements, finding transpose and diagonal elements, matrix addition/multiplication, checking for identity/sparse matrices, determinant calculation, and more. Memory addressing of 2D arrays is also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views2 pages

2D Array Practice Questions

This document contains 21 practice questions related to 2D arrays in C programming. The questions cover a range of topics including inputting and displaying 2D arrays, calculating sums and averages of elements, finding transpose and diagonal elements, matrix addition/multiplication, checking for identity/sparse matrices, determinant calculation, and more. Memory addressing of 2D arrays is also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2D Array Practice Questions

1. WAP to input a 2D array of size M*N and display it in tabular form.


2. WAP to input a 2D array of size M*N and find the sum and average of all the elements.
3. WAP to input a 2D array of size M*N and find the sum of individual rows and individual columns.
4. WAP to input a 2D array of size M*N and display boundary elements in matrix form.
5. WAP to input a 2D array of size M*N and display the transpose of it.
6. WAP to input a 2D array and find the sum of its diagonal elements.
7. WAP to input a 2D array and display diagonal elements in matrix form.
8. WAP to input 2 matrices from the user and add them.
9. WAP to input a matrix and check if its identity matrix or not.
10. WAP to input a matrix of order M*N and check if it’s sparse or dense matrix.
11. Write a program in C to calculate determinant of a 3 x 3 matrix.
12. Write a program to keep records and perform statistical analysis for a class of students. The
class may have up to 10 students. There are three quizzes during the term for computer
programming. Each student is identified by a four digit roll no. The program will print the
student scores and calculate and print the following statistics
1. High score & Low score for each quiz along with the roll number of that student.
2. Average of Each Quiz and overall average of all the 3 quizzes
3. Highest Average and Lowest average of all the three quizzes along with quiz no.
4. Highest marks & lowest marks of each student in the 3 quizzes along with the quiz no.
13. WAP to input 2 matrixes and multiply them.
14. WAP to input a matrix and print its upper triangular matrix.
15. WAP to input a matrix and print its Lower triangular matrix.
16. WAP to input a matrix and print it in zig zack form.
Example :- if matrix is 1 2 3 4
5678
9123
4591
Then output matrix will be
1234
8765
9123
1954
17. Suppose there is a game known as “MATCH THE TABLES”, in which the player picks up two
tables(each having 10 rows and 10 columns) and matches them. If out of 100 entries at least 90
corresponding entries match then the tables are said to be identical and the player is declared
the winner. Wap in ‘C’ to implement the above game.
18. Which of the following initializations of a 2d array are valid?

(i) int abc[2][2] = {1, 2, 3 ,4 } (ii) int abc[][] = {1, 2, 3 ,4 }


(iii) int abc[][] = {1, 2, 3 ,4 } (iv) int abc[2][] = {1, 2, 3 ,4 }
19. An array =X [-15……….10, 15……………40] requires one byte of storage. If beginning location is
1500 determine the location of X [5][20]for data stored as
(i) Column major wise (ii) Row major wise.
20. Consider the following declaration of a ‘two-dimensional array in C:

char a[100][100];

Assuming that the main memory is byte-addressable and that the array is stored starting from
memory address 0. Find the address of a[40][50] using row and column major.
21. Let A be a square matrix of size n x n. Consider the following program. What is the expected
output?
C = 100;
for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    {
        Temp = A[i][j] + C;
       A[i][j] = A[j][i];
        A[j][i] = Temp – C;
    }
for(i=0;i<n;i++)
    for(j=0;j<n;j++)
       printf(“%d ”,A[i][j]);

You might also like