Commit d046ff05 by ilahma

Upload New File

parent 3f38bf38
Showing with 82 additions and 0 deletions
#include <stdio.h>
int main() {
int r; //r - row of matrix
int c; //c stands for columns
int i;
int j;
float A[3][3];
float B[3][3];
float sumAB[3][3];
float subtractAB[3][3];
float multiplicationA[3][3];
float multiplicationB[3][3];
printf("Please, enter the rows and columns of matrices:\n THEY SHOULD BE EQUAL!!!\n");
scanf("%d%d", &r, &c);
printf("Please, enter the elements of the first matrix:\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
scanf("%f", &A[i][j]);
}
}
printf("Please, enter the elements of the second matrix:\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
scanf("%f", &B[i][j]);
}
}
printf("SUM\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
sumAB[i][j]= A[i][j] + B[i][j];
printf("%f, ", sumAB[i][j]);
}
printf("\n");
}
printf("SUBTRACTION\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
subtractAB[i][j]= A[i][j] - B[i][j];
printf("%f, ", subtractAB[i][j]);
}
printf("\n");
}
printf("Diagonals\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
if(i==j)
{
multiplicationA[i][j]= A[i][j] * multiplicationA[i][j];
}
}
printf("\n");
printf("%f, ",multiplicationA[i][j]);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment