Basic c program to add two matrices using an array. In this program, we can execute the addition of two matrices.
Matrix Definition in C
a matrix with just real numbers as elements. A rectangular array of quantities or expressions put out by rows and columns that is viewed as a single element and handled according to rules. A matrix is a rectangular array of numbers that are arranged in rows and columns. The numbers are referred to as the matrix’s elements or entries.
Array Definition in C
An array is a collection of data elements of the same type stored in contiguous memory regions. Arrays are a derived data type in the C programming language that may hold primitive data types like int, char, double, float, and so on.
C Program to Add Two Matrices Using an Array
//c program to add two matrices using an array
#include <stdio.h>
int main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
printf("Enter The Number of Rows and Column\n");
scanf("%d%d", &m, &n);
printf("Enter First Matrix\n");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &first[c][d]);
printf("Enter Second Matrix\n");
for (c = 0; c < m; c++)
for (d = 0 ; d < n; d++)
scanf("%d", &second[c][d]);
printf("Sum Of Matrix\n");
for (c = 0; c < m; c++) {
for (d = 0 ; d < n; d++) {
sum[c][d] = first[c][d] + second[c][d];
printf("%d\t", sum[c][d]);
}
printf("\n");
}
return 0;
}
Enter The Number of Rows and Column
2
2
Enter First Matrix
45
23
67
34
Enter Second Matrix
23
4
5
56
Sum Of Matrix
68 27
72 90
C Program to Find Reverse of a String Using Recursion
C Program to Implement Quick Sort Using Recursion
Quick Sort in C Program With Explanation
Quick Sort Program in C Using Recursion
Bubble Sort in Python Using Function
Bubble Sort in Python Using While Loop
Bubble Sort Program in Python Using List
Python Program to Print Inverted Pyramid Pattern
Python Program to Display Alphabet Pattern