#include<stdio.h>
int main()
{
int i, j, n, m;
printf("Enter row and column number : ");
scanf("%d %d", &n, &m);
int anik[n][m], rob[n][m], ar[n][m];
printf("\nEnter element for First matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("anik[%d][%d] = ",i,j);
scanf("%d", &anik[i][j]);
}
}
printf("\nEnter element for second matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("rob[%d][%d] = ",i,j);
scanf("%d", &rob[i][j]);
}
}
printf("\nFirst Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", anik[i][j]);
}
printf("\n");
}
printf("\nSecond Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", rob[i][j]);
}
printf("\n");
}
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
ar[i][j] = anik[i][j] + rob[i][j];
}
}
printf("\nAddition of Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", ar[i][j]);
}
printf("\n");
}
return 0;
}
int main()
{
int i, j, n, m;
printf("Enter row and column number : ");
scanf("%d %d", &n, &m);
int anik[n][m], rob[n][m], ar[n][m];
printf("\nEnter element for First matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("anik[%d][%d] = ",i,j);
scanf("%d", &anik[i][j]);
}
}
printf("\nEnter element for second matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("rob[%d][%d] = ",i,j);
scanf("%d", &rob[i][j]);
}
}
printf("\nFirst Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", anik[i][j]);
}
printf("\n");
}
printf("\nSecond Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", rob[i][j]);
}
printf("\n");
}
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
ar[i][j] = anik[i][j] + rob[i][j];
}
}
printf("\nAddition of Matrix : \n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
printf("%d ", ar[i][j]);
}
printf("\n");
}
return 0;
}
Comments
Post a Comment