0% found this document useful (0 votes)
25 views

Lect-16 Multidimensional Array (Practice)

The document provides practice problems on operations of two dimensional arrays in C++ including inputting and displaying arrays, calculating sums, transposes, diagonals, multiplications, upper half of an array, and adding and multiplying arrays.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Lect-16 Multidimensional Array (Practice)

The document provides practice problems on operations of two dimensional arrays in C++ including inputting and displaying arrays, calculating sums, transposes, diagonals, multiplications, upper half of an array, and adding and multiplying arrays.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Practice

Multidimensional Arrays
Programming Fundamentals
Practice
1. Write a menu driven C++ program to do following operation on two
dimensional array A of size m x n. You should use user-defined
functions which accept 2-D array A, and its size m and n as
arguments. The options are:
• To input elements into matrix of size m x n
• To display elements of matrix of size m x n
• Sum of all elements of matrix of size m x n
• To display row-wise sum of matrix of size m x n
• To display column-wise sum of matrix of size m x n
• To create transpose of matrix B of size n x m
2. Write user defined functions for square matrix to calculate
• Left diagonal sum
• Right diagonal sum
3. Write a user-defined function in C++ to display the multiplication of row element of two-dimensional array
A[4][6] containing integer.
4. Write a user defined function named Upper-half() which takes a two dimensional array A, with size N rows
and N columns as argument and prints the upper half of the array.
e.g.,
2 3 1 5 0                              2 3 1 5 0
7 1 5 3 1                                 1 5 3 1
2 5 7 8 1   Output will be:       1 7 8
0 1 5 0 1                                       0 1
3 4 9 1 5                                          5
5. Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the
elements of middle row and the elements of middle column.
[Assuming the 2D Array to be a square matrix with odd dimension i.e. 3x3, 5x5, 7x7 etc...]
Example, if the array contents is
3  5  4
7  6  9
2  1  8
Output through the function should be :
Middle Row : 7 6 9
Middle column : 5 6 1
6. Write a program to add two array A and B of size m x n.
7. Write a program to multiply array A and B of order NxL and LxM
 

You might also like