-
Notifications
You must be signed in to change notification settings - Fork 1
/
matrixMajorMinor.c
58 lines (58 loc) · 1.24 KB
/
matrixMajorMinor.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Created by sids on 23/10/18.
//
#include <stdio.h>
int create(int j, int k);
int main(){
int i,j;
printf("Enter the rows in the 2D array.\n");
scanf("%d",&i);
printf("Enter the columns in the 2D array.\n");
scanf("%d",&j);
create(i,j);
return 0;
}
int create(int j, int k){
int array[j][k],m,i;
printf("enter the numbers for the array.\n");
for(i=0;i<j;i++){
for(m=0;m<k;m++){
scanf("%d",&array[i][m]);
}
}
printf("The major is: \n");
for(i=0;i<j;i++){
for(m=0;m<k;m++){
if(i==m){
printf("%d ",array[i][m]);
}
}
printf("\n");
}
printf("The upper minor is: \n");
for(i=0;i<j;i++){
for(m=0;m<k;m++){
if(i==(m-1)){
printf("%d ",array[i][m]);
}
}
printf("\n");
}
printf("The lower minor is: \n");
for(i=0;i<j;i++){
for(m=0;m<k;m++){
if(i==(m+1)){
printf("%d ",array[i][m]);
}
}
printf("\n");
}
printf("The matrix is: \n");
for(i=0;i<j;i++){
for(m=0;m<k;m++){
printf("%d ",array[i][m]);
}
printf("\n");
}
return 0;
}