C program to calculate the matrix addition using a two dimensional array.

 

C program
C PROGRAM 

C program to calculate the matrix addition using a two-dimensional array

#include <stdio.h>
#include <conio.h>
void main()
{
  int a[10][10],b[10][10],c[10][10],i,j,rows,columns;
  printf("Enter the number of the rows");
  scanf("%d",&rows);
  printf("\n Enter the number of the columns");
  scanf("%d",&columns);
  printf(" Enter the elements of the first matrix \n");
  for(i=0;i<rows;i++)
  {
    for(j=0;j<columns;j++)
    {
      scanf("%d",&a[i][j]);
    }
   }
   printf(" Enter the elements of the second matrix \n");
     
  for(i=0;i<rows;i++)
  {
    for(j=0;j<columns;j++)
    {
      scanf("%d",&b[i][j]);
    }
   }
   printf("sum of two matrix is \n");
   for(i=0;i<rows;i++)
  {
    for(j=0;j<columns;j++)
    {
      c[i][j]=a[i][j]+b[i][j];
      printf("%d \n",c[i][j]);
    }
   }
   getch();
 }

OUTPUT :

Enter the number of rows2
 Enter the number of columns2
 Enter the elements of the first matrix 
1 1
1 1
 Enter the elements of the second matrix 
1 1
1 1
sum of two matrix is 




Process finished.

Comments

Popular posts from this blog

Write a program to calculate a students result based on two examinations, 1 sports event, and 3 activities conducted. The weightage of activities= 30%, sports= 20% , and examinations= 50%.

Determine the intensity of shear of an oil having viscosity= 1 poise. The oil is used for lubricating the clearance between a shaft of diameter 10 cm and its journal bearing. The clearance is 1.5mm and the shaft rotates at 150 r.p.m.