Search This Blog

Monday, April 20, 2020

Additon of Matrix in C Programming

             C-Programming:-

In this tutorial you will learn :-

 

// Write a program to perform addition of two matrix 3 x 3 and greater a result matrix

#include<stdio.h>
int main()
{
int a[3][3] ,  b[3][3] , c[3][3] ;
int i , j ;
printf("enter the value of matrix a");
for(i=0 ; i<3 ; i++ )
{
for(j=0 ; j<3 ; j++)
{
scanf("%d",& a[i][j]);
}
}
printf("enter the value of second matrix ");
for("i=0 ; i<3 ; i++)
{
for(j=0 ; j<3 ; j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0 ; i<3 ; i++)
{
for(j=0 ; j<3 ; j++)
{
c[i][j] = a[i][j] + b[i][j] ;
}
printf("addition of matrix are ");
for(i=0 ; i<3 ; i++)
{
for(i=0 ; i<3 ; i++)\
{
printf("%d", c[i][j]);
}
printf(" \ n ");
}
return ( 0 );
}

 OUTPUT:-

enter the value of first matrix 1 2 3 4 5 6 7 8 9
enter the value of second matrix 1 2 3 4 5 6 7 8 9
addition of matrix is   2    4    6  
                                     8    10   12
                                    14   16   18 

Mr. abhijeet dwivedi

Developer

Hey, I'm Abhijeet

0 comments:

Post a Comment

If you have any doubt, please let me know