Assigment 8 Demonstration of 2d - Array
Assigment 8 Demonstration of 2d - Array
Assigment 8 Demonstration of 2d - Array
Two-dimensionalArrays
The simplest form of multidimensional array is the two-dimensional
array. A two-dimensional array is, in
essence, a list of one-dimensional arrays. To declare a two-dimensional
integer array of size [x][y], you
would write something as follows −
type arrayName [ x ][ y ];
Where type can be any valid C data type and arrayName will be a valid
C identifier. A two-dimensional
array can be considered as a table which will have x number of rows and
y number of columns. A two
dimensional array a, which contains three rows and four columns can be
shown as follows –
int a[3][4];
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j;
int matrix[rows][cols];
// Initialize max and min with the first element of the matrix
int max_element = matrix[0][0];
int min_element = matrix[0][0];
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j, sum = 0;
int matrix[rows][cols];
Getch();
}
3) Write a program to calculate sum of all even elements of a matrix
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j, sum = 0;
int matrix[rows][cols];
Getch();
}
4) Write a program to calculate sum of all upper triangular matrix
elements
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j, sum = 0;
int matrix[rows][cols];
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i,j, sum = 0;
int matrix[rows][cols];
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j;
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows1, cols1, rows2, cols2, i, j, k;
// Matrix multiplication
for (i = 0; i < rows1; i++) {
for (j = 0; j < cols2; j++) {
for (k = 0; k < cols1; k++) {
result[i][j] += matrix1[i][k] * matrix2[k][j];
}
}
}
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j;
Getch();
}
#include <stdio.h>
#include<conio.h>
void main() {
int rows, cols, i, j;
int matrix[rows][cols];
int rowSum[rows], colSum[cols];
Getch();
}
10) Write a program to check whether a input matrix is identity matrix or
not.
#include <stdio.h>
#include<conio.h>
void main() {
int matrix[3][3], isIdentity = 1;
if (isIdentity) {
printf("The matrix is an identity matrix.\n");
} else {
printf("The matrix is not an identity matrix.\n");
}
Getch();
}