Sum of two Matrix

Sum of two Matrix

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Sum of two Matrix
Sum of two Matrix

Write a C program to Sum of two Matrix

PROGRAM: Sum of two Matrix

/* Sum of two Matrix */
#include<stdio.h>

int main()
{
  int a[5][5],b[5][5],c[5][5];
  int i,j;

  for(i=0;i<5;i++)
  {
    printf("\nEnter elements of %d row of first Matrix: ",i+1);
    for(j=0;j<5;j++)
      scanf("%d",&a[i][j]);
  }
  
  for(i=0;i<5;i++)
  {
    printf("\nEnter elements of %d row of 2nd Matrix: ",i+1);
    for(j=0;j<5;j++)
      scanf("%d",&b[i][j]);
  }
  
  printf("\nSum of Matrix:\n\n");
  for(i=0;i<5;i++)
  {
    for(j=0;j<5;j++)
    {
      c[i][j]=a[i][j]+b[i][j];
      printf("%3d ",c[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *