Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
emonyi
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bc9e045d
authored
6 years ago
by
emonyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
7b4ae79f
master
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
lab4/task2.c
lab4/task2.c
0 → 100644
View file @
bc9e045d
#include <stdio.h>
int
main
()
{
int
dimension
,
x
,
y
;
printf
(
"please enter the rows and columns of the two square matrices: "
);
scanf
(
"%d"
,
&
dimension
);
int
marray1
[
dimension
][
dimension
];
int
marray2
[
dimension
][
dimension
];
printf
(
"enter the values of the first matrix:
\n
"
);
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
scanf
(
"%d"
,
&
marray1
[
x
][
y
]);
}
}
printf
(
"The first matrix is:
\n
"
);
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
printf
(
"%d, "
,
marray1
[
x
][
y
]);
}
printf
(
"
\n
"
);
}
printf
(
"enter the values of the second matrix:
\n
"
);
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
scanf
(
"%d"
,
&
marray2
[
x
][
y
]);
}
}
printf
(
"The second matrix is:
\n
"
);
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
printf
(
"%d, "
,
marray2
[
x
][
y
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
The sum of entered matrices are:
\n
"
);
int
sum
[
dimension
][
dimension
];
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
sum
[
x
][
y
]
=
marray1
[
x
][
y
]
+
marray2
[
x
][
y
];
printf
(
"%d, "
,
sum
[
x
][
y
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
The difference of entered matrices are:
\n
"
);
int
diff
[
dimension
][
dimension
];
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
for
(
y
=
0
;
y
<
dimension
;
y
++
)
{
diff
[
x
][
y
]
=
marray1
[
x
][
y
]
-
marray2
[
x
][
y
];
printf
(
"%d, "
,
diff
[
x
][
y
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
The sum of products of diagonals of the first matrices are:
\n
"
);
int
product1
=
1
;
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
product1
=
product1
*
marray1
[
x
][
x
];
}
int
product2
=
1
;
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
product2
=
product2
*
marray1
[
x
][
dimension
-
1
-
x
];
}
printf
(
"%d"
,
product1
+
product2
);
printf
(
"
\n
The sum of products of diagonal of the second matrices are:
\n
"
);
int
product3
=
1
;
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
product3
=
product3
*
marray2
[
x
][
x
];
}
int
product4
=
1
;
for
(
x
=
0
;
x
<
dimension
;
x
++
)
{
product4
=
product4
*
marray2
[
x
][
dimension
-
x
-
1
];
}
printf
(
"%d"
,
product3
+
product4
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment