F How to implement matrix addition in C programming? | CodeTheta

How to implement matrix addition in C programming?

January 18, 2014

/* http://native-code.blogspot.com */
#include<stdio.h>
#include<conio.h>
void main()
{
int a[25][25],b[25][25],c[25][25],i,j,row,col;
printf("/* http://native-code.blogspot.com */\n\nEnter the no. of rows and colomns");
scanf("%d%d",&row,&col);
printf("\nEnter the elements of 1st matrix:");
for(i=0;i<row;i++)
for(j=0;j<col;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the elements of 2nd matrix:");
for(i=0;i<row;i++)
for(j=0;j<col;j++)
scanf("%d",&b[i][j]);
printf("\nAddition is as follows:");
for(i=0;i<row;i++)
{
   for(j=0;j<col;j++)
   {
       c[i][j]=a[i][j]+b[i][j];
       printf("%d ",c[i]);
   }
   printf("\n");
}
getch();
}
/* http://native-code.blogspot.com */

Post a Comment