Tag Archives: Matrix

C program to multiply two matrix using pointers

Write a C program to multiply two matrix using pointers. How to input and multiply two matrix using pointer in C programming. Logic to multiply two matrix using pointer in C.

Example

Input

Input elements of matrix1:
10 20 30
40 50 60
70 80 90
Input elements of matrix2:
1 2 3
4 5 6
7 8 9

Output

Product of matrices is :
300 360 420
660 810 960
1020 1260 1500

C program to add two matrix using pointers

Write a C program to add two matrix using pointers. C program to input two matrix from user and find sum of both matrices using pointers.

Example

Input

Input matrix1:
1 2 3
4 5 6
7 8 9
Input matrix2:
9 8 7
6 5 4
3 2 1

Output

Sum of both matrices:
10 10 10
10 10 10
10 10 10

How to access two dimensional array using pointers in C programming?

How to access two dimensional array using pointers in C programming? Write a C program to input and print elements of a two dimensional array using pointers and functions.

Example

Input

Input elements in 3x3 matrix:
1 2 3
4 5 6
7 8 9

Output

Elements of 3x3 matrix:
1 2 3
4 5 6
7 8 9

Multi-dimensional array in C – Declare, initialize and access

Multi-dimensional array is an array of array or more precisely collection of array. Unlike one-dimensional array, multi-dimensional array stores collection of array.

Let us revise the concept of dimension.

• One-dimensional array : Collection of data/values.
• Two-dimensional array : Collection of one-dimensional array.
• Three-dimensional array : Collection of two-dimensional array.
• N-dimensional array : Collection of N-1 dimensional array.

C program to find sum of lower triangular matrix

Write a C program to read elements in a matrix and find sum of lower triangular matrix. How to find sum of lower triangular matrix in C. Logic to find sum of lower triangular matrix in C programming.

Example

Input

Input elements in matrix:
1 0 0
4 5 0
7 8 9

Output

Sum of lower triangular matrix = 19

C program to find sum of upper triangular matrix

Write a C program to read elements in a matrix and find sum of upper triangular matrix. How to find sum of upper triangular matrix in C. Logic to find sum of upper triangular matrix.

Example

Input

Input matrix elements:
1 2 3
0 5 6
0 0 9

Output

Sum of upper triangular matrix = 11

C program to find determinant of a matrix

Write a C program to read elements in a matrix and find determinant of the given matrix. C program to find determinant of a 2x2 matrix and 3x3 matrix. Logic to find determinant of a matrix in C programming.

Example

Input

Input elements in 2x2 matrix:
1 2
3 4

Output

Determinant of the matrix = -2

C program to check symmetric matrix

Write a C program to read elements in a matrix and check whether the given matrix is symmetric matrix or not. How to check symmetric matrix in C. Logic to check symmetric matrix in C programming.

Example

Input

Input matrix elements:
1 2 3
2 4 5
3 5 8

Output

Given matrix is symmetric matrix.

C program to find transpose of a matrix

Write a C program to read elements in a matrix and find transpose of the given matrix. How to find transpose of a given matrix in C. Logic to find transpose of a matrix in C programming.

Example

Input

Input elements in matrix:
1 2 3
4 5 6
7 8 9

Output

Transpose:
1 4 7
2 5 8
3 6 9

C program to check sparse matrix

Write a C program to read elements in a matrix and check whether matrix is Sparse matrix or not. C program for determining sparse matrix. How to check sparse matrix in C. Logic to check sparse matrix in C programming.

Example

Input

Input elements in matrix:
1 0 3
0 0 4
6 0 0

Output

The given matrix is Sparse matrix