Reload your browser or click the button below to continue.
Disable AdBlock Plus:
Click on the icon in yor browser toolbar.
Click the blue button next to "Block Ads On:"
Click the red "Refresh" button or click the button below to continue.
Disable Adguard AdBlocker:
Click on the icon in yor browser toolbar.
Click on the toggle next to "Protection on this website".
Reload your browser or click the button below to continue.
Disable uBlock Origin:
Click on the icon in yor browser toolbar.
Click on the big blue "power" icon.
Reload your browser or click the button below to continue.
Two dimensional array exercises in C Programming in C
Sum of elements in a two dimensional array: Write a program that reads the R and C dimensions of a two-dimensional array T of type int (maximum dimensions: 50 rows and 50 columns). Fill in the array with values entered on the keyboard and display the array and the sum of all its elements....
Sum of rows and columns in a two dimensional array: Write a program that reads the R and C dimensions of a two-dimensional array T of type int (maximum dimensions: 50 rows and 50 columns). Fill in the array with values entered on the keyboard and display the array and the sum of each row and column us...
Convert a two dimensional array into one dimensional array: Write a program that transfers a two-dimensional array R and C (maximum dimensions: 10 rows and 10 columns) into a one-dimensional array V of size R * C.
\(\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix}\Rightarrow (a \ b \ c \ d \ e \ f \ g \ h \ i \ j \ k \ l )\)...
Split a string by space into words: Write a program that splits a string by space into words. Use an array of strings to store the words...
Determinant of a 2 x 2 matrix: Write a program that calculates the determinant of a 2 x 2 matrix.
\(\begin{vmatrix} a & b \\c & d \end{vmatrix} = a \times d - b \times c\)...
Determinant of a 3 x 3 matrix: Write a program that calculates the determinant of a 3 x 3 matrix.
\(\begin{vmatrix} a & b & c\\ d & e & f \\ g & h & i \end{vmatrix} = a \times \begin{vmatrix} e & f \\h & i \end{vmatrix}- b \times \begin{vmatrix} d & f \\g & i \end{vmatrix}+ c \times \begin{vmatrix} d & e \\g & h \end{vmatrix}= a \times (e \times i - f \times h) - b \times (d \times i - f \times g ) + c \times (d \times h - e \times g) \)...
Number pattern 6: \(\begin{array}{ccccc}1&2&3&4&5\\16&17&18&19&6\\15&24&25&20&7\\14&23&22&21&8\\13&12&11&10&9\end{array}\)
Write a program that reads a number and displays the above patt...
Creation of a matrix defined by a relation: Let \(A=\{a_{ij}\}_{1\leq i\leq 5, 1\leq j\leq 5}\) be a matrix defined by \(a_{ij}=\frac{1}{i+j}\). Write a program that creates such a matrix in a two-dimensional array and displays the values....
Check if a matrix is symmetric: Write a program that reads a square matrix and checks whether it is symmetric.
A square matrix is called symmetric if for all values of i and j, a[i][j]=a[j][i]....
Subtract of two matrices (storage in a new matrix): Write a program that performs the substraction of two matrices A and B of the same dimensions R and C.
The result of the substraction will be stored in a third matrix SUM which will then be displayed.
\(\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix} - \begin{pmatrix} a' & b' & c' & d' \\e' & f' & g' & h' \\ i' & j' & k' & l' \end{pmatrix} = \begin{pmatrix} a-a' & b-b' & c-c' & d-d' \\e-e' & f-f' & g-g' & h-h' \\ i-i' & j-j' & k-k' & l-l' \end{pmatrix}\)...
Subtract of two matrices (storage in the first matrix): Write a program that performs the substraction of two matrices A and B of the same dimensions R and C.
Matrix B is subtracted from A.
\(\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix} - \begin{pmatrix} a' & b' & c' & d' \\e' & f' & g' & h' \\ i' & j' & k' & l' \end{pmatrix} = \begin{pmatrix} a-a' & b-b' & c-c' & d-d' \\e-e' & f-f' & g-g' & h-h' \\ i-i' & j-j' & k-k' & l-l' \end{pmatrix}\)...
Interchange diagonals of a square matrix: Write a program that interchanges the diagonals of a square matrix.
\(\begin{pmatrix} a & b & c \\d & e & f \\ g & h & i \end{pmatrix} becomes \begin{pmatrix} c & b & a \\d & e & f \\ i & h & g \end{pmatrix} \)...
Check whether a matrix is an upper triangular matrix: Write a program that checks whether a matrix is an upper triangular matrix.
A matrx is said to be an upper triangular matrix if all values under the main diagonal are zeros....
Check whether a matrix is a lower triangular matrix: Write a program that checks whether a matrix is a lower triangular matrix.
A matrx is said to be a lower triangular matrix if all values above the main diagonal are zeros....
Check Identity matrix: Write a program that checks whether a matric is an Identity matrix.
Identity matrix is a square matrix whose main diagonal elements is equal to 1 and other elements are 0....
Check sparse matrix: Write a program that checks whether a matric is a sparse matrix.
A sparse matrix is a special matrix where more than half of its elements are equal to zero. ...
Check symmetric matrix: Write a program that checks whether a matric is a symmetric matrix.
A symmetric matrix is a square matrix which is equal to its transpose.
...
Function sorting an array of strings: Write a program that reads 10 words and stores them in an array of strings. write a function that sorts the 10 words lexicographically using the strcmp and strcpy functions. Display the sorted array....
Transpose of a matrix using an iterative function: Write the function TRANSPO_MATRIX with 3 parameters MAT, R and C, CMAX transposes the MAT matrix.
TRANSPO_MATRICE returns a logical value which indicates if the dimensions of the matrix are such that the transposition could be carried out.
Write a sm...
Unit Matrix: Write a program that constructs and displays a unitary square matrix M of dimension N. A unitary matrix is a matrix, such that:
\(u_{ij}=\Big\{\begin{array}{c c c} 1 & if & i=j \\ 0 & if & i\neq j \end{array}\)...
Transposition of a matrix (storage into a new matrix): Write a program that performs the transposition tA of a matrix A of dimensions N and M into a matrix of dimensions M and N.
The transposed matrix will be stored in a second matrix B which will then be displayed.
\(^{t}A = ^{t}\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix}= \begin{pmatrix} a & e & i \\ b & f & j \\ c & g & k \\ d & h & l\end{pmatrix}\)...
Transposition of a matrix (permutation of the elements): Write a program that performs the transposition tA of a matrix A of dimensions N and M into a matrix of dimensions M and N.
The matrix A will be transposed by permutation of the elements
\(^{t}A = ^{t}\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix}= \begin{pmatrix} a & e & i \\ b & f & j \\ c & g & k \\ d & h & l\end{pmatrix}\)...
Multiplication of a matrix by a real (storage in a new matrix): Write a program that multiplies an A matrix by a real X.
The result of the multiplication will be memorized in a second matrix B which will then be displayed.
\(X \times \begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix}= \begin{pmatrix} X \times a & X \times b & X \times c & X \times d \\X \times e & X \times f & X \times g & X \times h \\ X \times i & X \times j & X \times k & X \times l \end{pmatrix}\)...
Multiplication of a matrix by a real (storage in the same matrix): Write a program that multiplies an A matrix by a real X.
The elements of matrix A will be multiplied by X.
\(X \times \begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix}= \begin{pmatrix} X \times a & X \times b & X \times c & X \times d \\X \times e & X \times f & X \times g & X \times h \\ X \times i & X \times j & X \times k & X \times l \end{pmatrix}\)...
Sum of two matrices (storage in a new matrix): Write a program that performs the addition of two matrices A and B of the same dimensions R and C.
The result of the addition will be stored in a third matrix SUM which will then be displayed.
\(\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix} + \begin{pmatrix} a' & b' & c' & d' \\e' & f' & g' & h' \\ i' & j' & k' & l' \end{pmatrix} = \begin{pmatrix} a+a' & b+b' & c+c' & d+d' \\e+e' & f+f' & g+g' & h+h' \\ i+i' & j+j' & k+k' & l+l' \end{pmatrix}\)...
Sum of two matrices (storage in the first matrix): Write a program that performs the addition of two matrices A and B of the same dimensions R and C.
Matrix B is added to A.
\(\begin{pmatrix} a & b & c & d \\e & f & g & h \\ i & j & k & l \end{pmatrix} + \begin{pmatrix} a' & b' & c' & d' \\e' & f' & g' & h' \\ i' & j' & k' & l' \end{pmatrix} = \begin{pmatrix} a+a' & b+b' & c+c' & d+d' \\e+e' & f+f' & g+g' & h+h' \\ i+i' & j+j' & k+k' & l+l' \end{pmatrix}\)...
Multiplication of two matrices: By multiplying a matrix A of dimensions R and C with a matrix B of dimensions C and P, a matrix MULT of dimensions R and P is obtained:A (R, C) * B (C, P) = MULT (R, P)
The multiplication of two matrices is done by multiplying the components of the t...
Pascal triangle: Write a program that builds the PASCAL triangle of degree N and stores it in a square matrix P of dimension N + 1.
Method:
Calculate and display only the values up to the main diagonal (included). Limit the degree to enter by the user to 13.
Construc...
Search for saddle point: Search in a given matrix A for elements that are both a maximum on their row and a minimum on their column. These elements are called saddle points. Display positions and values of all found saddle points.
Examples: The underlined elements are saddle...
Availability in a hotel: To manage the availability of the rooms in his hotel, the owner asks you to write a program that uses an array rooms[10][40] whose values are 0s and 1s. The value of rooms[i][j] is 1 if the room j of the floor i is occupied, this value is 0 if this r...
Sort an array of strings: Write a program that reads 10 words and stores them in an array of strings. Sort the 10 words lexicographically using the strcmp and strcpy functions. Display the sorted array....
Sum of the elements of a matrix using an iterative function: Write the function SUM_MATRIX of the long type which calculates the sum of the elements of a MAT matrix of the type int. Choose the necessary parameters. Write a small program that tests the function SUM_MATRIX....
Sum of 2 matrices using an iterative function: Write the function ADDITION_MATRIX which carries out the addition of the matrices following: MAT1 = MAT1 + MAT2
Choose the necessary parameters and write a small program that tests the function ADDITION_MATRIX....
Multiplication of a matrix by a number using an iterative function: Write the MULTI_MATRIX function which multiplies the matrix MAT1 by an integer X: MAT1 = X * MAT1
Choose the necessary parameters and write a small program that tests the MULTI_MATRIX function....
Multiplication of two matrices using an iterative function: Write the function MULTI_2_MATRICES which performs the multiplication of two matrices MAT1 (dimensions R and P) and MAT2 (dimensions P and C) in a third matrix MAT3 (dimensions R and C): MAT3 = MAT1 * MAT2
Suppose that the maximum dimensions of the t...
Read the dimension and the elements on a matrix using an iterative function: Write the function READ_NB_ROWS which reads the number of rows R of a matrix.
Write the function READ_NB_COLUMNS which reads the number of columns C of a matrix.
Write the function READ_MATRIX taking 3 parameters MAT, R, and C which reads the compone...