-
Notifications
You must be signed in to change notification settings - Fork 0
/
checks.c
36 lines (33 loc) · 785 Bytes
/
checks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Mantu Matei 312CA 2022-2023
#include <stdio.h>
int check_R(int ind, int pow, int *m, int *n, int size)
{
if (ind > size - 1 || ind < 0)
printf("No matrix with the given index\n");
else if (m[ind] != n[ind])
printf("Cannot perform matrix multiplication\n");
else if (pow < 0)
printf("Power should be positive\n");
else
return 1;
return 0;
}
int check_M(int i, int j, int size, int *n, int *m)
{
if (i > size || j > size || i < 0 || j < 0) {
printf("No matrix with the given index\n");
return 0;
} else if (n[i] != m[j]) {
printf("Cannot perform matrix multiplication\n");
return 0;
}
return 1;
}
int matrix_exists(int ind, int size)
{
if (ind > size - 1 || ind < 0)
printf("No matrix with the given index\n");
else
return 1;
return 0;
}