Lab7-Mech
Lab7-Mech
Computer Programming
ECO 123
12/10/2021 1
Lab 7
Lab objectives
1. Notes on multidimensional Arrays
2. Exercises on multidimensional Arrays
• Multidimensional Arrays
12/10/2021 2
Declaration of an Array:
Ex:
int num[2][2]; //Array of 2 rows and 2 columns of integer numbers
integers
12/10/2021 3
Initialization of an Array:
12/10/2021 4
To access any element of the array we simply write the array name
and the element index.
Ex:-
int Numbers[3][3];
Numbers[2][1]=3; //Setting the element in third row and second
column to 3
12/10/2021 5
Ex1: C Program to read and print a RxC
Matrix, R and C must be input by User
12/10/2021 6
12/10/2021 7
12/10/2021 8
Ex2: C Program to read a matrix and find sum,
product of all elements of two dimensional
(matrix) array
12/10/2021 9
12/10/2021 10
12/10/2021 11
Ex3: C program to transpose a matrix
12/10/2021 12
12/10/2021 13
Ex4: C program to read a matrix and print it's
diagonals.
12/10/2021 14
12/10/2021 15
12/10/2021 16
Ex5: C program to find sum and subtraction
of two matrices
12/10/2021 17
12/10/2021 18
12/10/2021 19
12/10/2021 20
12/10/2021 21
Ex6: C program to find multiplication of two matrices
12/10/2021 22
12/10/2021 23
12/10/2021 24
12/10/2021 25
12/10/2021 26
Ex7: C program to interchange the rows in
the matrix
12/10/2021 27
12/10/2021 28
12/10/2021 29
12/10/2021 30
Ex8: C program to arrange row elements in
ascending order.
12/10/2021 31
12/10/2021 32
12/10/2021 33
12/10/2021 34