Array addition using Two-Dimensional Array in C


This program is about array addition of two given arrays using for loop and print the sum array.

Source Code

#include<stdio.h>
int main()
{
  int r,c,a[10][10],i,j,b[10][10],t[10][10];
  printf("\nEnter the row limit:");
  scanf("%d",&r);
  printf("\nEnter the column limit:");
  scanf("%d",&c);
  printf("\nEnter the values:");
  for(i=0;i<r;i++)
  {
    for(j=0;j<c;j++)
    {
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<r;i++)
  {
    for(j=0;j<c;j++)
    {
      scanf("%d",&b[i][j]);
    }
  }
  for(i=0;i<r;i++)
  {
    for(j=0;j<c;j++)
    {
      t[i][j]=a[i][j]+b[i][j];
    }
  }
  printf("Addition Value:\n");
  for(i=0;i<r;i++)
  {
    for(j=0;j<c;j++)
    {
      printf("\t%d",t[i][j]);
    }
    printf("\n");
  }
  return 0;
}
To download raw file Click Here

Output

Enter the row limit:2
Enter the column limit:2
Enter the values:1
2
3
4
5
6
7
8
Addition Value:
6  8
10 12

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes