Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

University of BATNA 2

Faculty : Mathematics and Computer Science


Department : Computer Science
Year of study : First Year engineer
Module : Algorithmic and Data Structures 1 Academic Year : 2023/2024
Tutorial Serie 5
Matrices « two-dimensional arrays »

Exercise 1

Let A an integer matrix of « N » rows et « M » columns (N≤100 and M≤80)


Write an algorithm that allows you to :
1. Invert the elements of the row « p » in the matrix A.
2. Determine and display the number of even values and the number of odd values in matrix A.

Exercise 2

Let MAT be a square matrix of integers of order N (N≤100).


Write an algorithm that allows you to :
1. Display the elements of the main diagonal of the MAT matrix.
2. Display the elements of the secondary diagonal (anti-diagonal) of the MAT matrix.
3. Calculate and display the trace of the MAT matrix.
« the trace of a matrix is the sum of elements of its main diagonal ».

Exercise 3
Write an algorithm to construct and display Pascal’s triangle.
Example : for a matrix (6,6)
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1

Page 1/1

You might also like