C Program to add two 2D arrays elements

Simple C program to add two 2D arrays.
 
#include<stdio.h>
int main()
{
 int arr1[3][3]={1,2,3,
                 4,5,6,
                 7,8,9};
 int arr2[3][3]={19,18,17,
                 16,15,14,
                 13,12,11};
 int arr[3][3],i=0,j=0;
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
  arr[i][j]=arr1[i][j]+arr2[i][j];
  }
    }
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
  printf("%d ",arr[i][j]);
  }
  printf("\n");
   }
return 0;        
}

Popular posts from this blog