In this program, we are going to share a **C program to represent linear equations in matrix form**. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to represent linear equations in matrix form with the output.

We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.

C

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include <stdio.h> #include <stdlib.h> int main(void) { char var[] = { 'x', 'y', 'z', 'w' }; printf("Enter the number of variables in the equations: "); int n; scanf("%d", &n); printf("\nEnter the coefficients of each variable for each equations"); printf("\nax + by + cz + ... = d"); int mat[n][n]; int constants[n][1]; int i,j; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &mat[i][j]); } scanf("%d", &constants[i][0]); } printf("Matrix representation is: "); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { printf(" %f", mat[i][j]); } printf(" %f", var[i]); printf(" = %f", constants[i][0]); printf("\n"); } return 0; } |

Enter the number of variables in the equations: 3

Enter the coefficients of each variable for each equations

ax + by + cz + … = d

1 2 3 4

1 2 6 8

2 3 9 8

Matrix representation is:

1 2 3 x = 4

1 2 6 y = 8

2 3 9 z = 8

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- C program to implement bit flipping
- C program to implement hashing
- C program to implement SJF algorithm
- stdio.h library functions list in c
- conio.h functions list in c
- C program remove spaces, blanks from a string
- How to write c program code for pow
- Program to delete n characters from a given position in a given string
- C program to solve the Number of stopping station problem
- C implementation of inserting a new node to a link list