Commit 7c060333 by makuks

Upload New File

parent f2fac9ea
Showing with 91 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
int main (){
int n;
printf("insert the size of the first matrices (max10):");
scanf("%d", &n);
int array[n][n];
int array2[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
array[i][j]= rand() % 10;
array2[i][j]= rand() % 10;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
printf("%d ", array[i][j]);
}
printf("\n");
}
printf("\n");
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
printf("%d ", array2[i][j]);
}
printf("\n");
}
// Adding Two matrices
int sum[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
{
sum[i][j]=array[i][j]+array2[i][j];
}
}
printf("\nSum of two matrix is: \n\n");
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
{
printf("%d ",sum[i][j]);
if(j==n-1)
{
printf("\n\n");
}
}
}
// subtracting Two matrices
int sub[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
{
sub[i][j]=array[i][j]-array2[i][j];
}
}
printf("\nSub of two matrix is: \n\n");
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
{
printf("%d ",sub[i][j]);
if(j==n-1)
{
printf("\n\n");
}
}
}
int m = 1;
int k = 1;
for(int i = 0; i < n; i++){
m = m * array[i][i];
k = k * array[i][n - i - 1];
}
//liida k ja m
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