March 28, 2024

Telugu Tech Tuts

TimeComputers.in

C In Telugu Addition of Two Matrix Part30

C Tutorial In Telugu Addition of Two Matrix

This c program add two matrices i.e. compute the sum of two matrices and then print it. Firstly user will be asked to enter the order of matrix ( number of rows and columns ) and then two matrices. For example if the user entered order as 2, 2 i.e. two rows and two columns and matrices as
First Matrix :-
1 2
3 4
Second matrix :-
4 5
-1 5
then output of the program ( sum of First and Second matrix ) will be
5 7
2 9
C programming code

#include

int main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];

printf(“Enter the number of rows and columns of matrixn”);
scanf(“%d%d”, &m, &n);
printf(“Enter the elements of first matrixn”);

for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &first[c][d]); printf("Enter the elements of second matrixn"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &second[c][d]); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) sum[c][d] = first[c][d] + second[c][d]; printf("Sum of entered matrices:-n"); for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < n ; d++ ) printf("%dt", sum[c][d]); printf("n"); } return 0; }