This is a C Program to find the basis and dimension of the given matrix.

Here is source code of the C Program to Find Basis and Dimension of a Matrix. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`#include<stdio.h>`

int main() {

int a[3][3], i, j;

long determinant;

printf("Enter the 9 elements of matrix: ");

for (i = 0; i < 3; i++)

for (j = 0; j < 3; j++)

scanf("%d", &a[i][j]);

printf("\nThe matrix is\n");

for (i = 0; i < 3; i++) {

printf("\n");

for (j = 0; j < 3; j++)

printf("%d\t", a[i][j]);

`}`

determinant = a[0][0] * ((a[1][1] * a[2][2]) - (a[2][1] * a[1][2]))

- a[0][1] * (a[1][0] * a[2][2] - a[2][0] * a[1][2]) + a[0][2]

* (a[1][0] * a[2][1] - a[2][0] * a[1][1]);

if (determinant != 0)

printf("The vectors forms the basis of R %d as the determinant is non-zero", 3);

`else`

printf("The vectors doesn't form the basis of R %d as the determinant is zero", 3);

return 0;

`}`

Output:

$ gcc BasisDimension.cpp $ ./a.out Enter the number of vectors: 3 Enter the vectors one by one: 1 2 3 2 3 4 3 4 5 The vectors doesn't form the basis of R3 as the determinant is zero

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

advertisement

advertisement

Here’s the list of Best Books in C Programming, Data Structures and Algorithms.

**Related Posts:**

- Practice Computer Science MCQs
- Check C Books
- Practice BCA MCQs
- Check Computer Science Books
- Watch Advanced C Programming Videos