matrix sum
- #include
- main()
- {
- int mat1[3][3],mat2[3][3],mat3[3][3],row,col,i,j;
- printf("enter the number of row");
- scanf("%d",&row);
- printf("enter the number of colom");
- scanf("%d",&col);
- printf("for first matrix");
- for(i=0;i
for(j=0;j {
- printf("enter %d row %d col",i+1,j+1);
- scanf("%d",&mat1[i][j]);
- printf("matrix is\n");
- }
- printf("for second matrix");
- for(i=0;i
for(j=0;j {
- printf("enter %d row %d col",i+1,j+1);
- scanf("%d",&mat2[i][j]);
- printf("matrix is \n");
- }
- for(i=0;i
for(j=0;j {
- mat3[i][j]=mat1[i][j]+mat2[i][j];
- printf("matrix is\n");
- }
- for(i=0;i
printf("%d\t",mat3[i][j]);
- printf("\n");
- }
tranpose of matrix
~ #include
main()
{
int mat1[4][4]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
int mat2[4][4];
int r;
int c;
int max = 0;
system("clear");
puts("Orignal Matrix :-");
for(r=0;r<4;r++)
{
for(c=0;c<4;c++)
{
printf("%d ",mat1[r][c]);
mat2[c][r] = mat1[r][c];
}
printf("\n");
}
puts("Transposed Matrix :-");
for(r=0;r<4;r++)
{
for(c=0;c<4;c++)
{
printf("%d ",mat2[r][c]);
if(mat2[r][c] > max) max = mat2[r][c];
}
printf("\n");
}
printf("\n\nMaximum number from the matrix is %d\n",max);
}