Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0de2186

Browse files
Merge branch 'ComputeNepal:master' into master
2 parents ab22b26 + 134680d commit 0de2186

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+736
-206
lines changed

‎.github/pull_request_template.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## New Pull Request
2+
3+
<!-- Before Submitting the pull request make sure the following checklist is complete. -->
4+
5+
- [ ] Descriptive names
6+
- [ ] Well-Commented Code
7+
- [ ] Descriptive Commit
8+
- [ ] Well Documented readme.md
9+
- [ ] Format for pull request [type]: Description
10+
11+
<!-- For referencing the Issue solved use Fixed: #issueNumber -->

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.exe
2+
*.out
23
*.o

‎Array Questions/q1.c‎ renamed to ‎Array Questions/1_largest_smallest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ int main(){
2020
}
2121
printf("Largest: %d, smallest: %d\n",largest, smallest);
2222
return 0;
23-
}
23+
}

‎Array Questions/q2.c‎ renamed to ‎Array Questions/2_read_age_of_40_sort_them.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ int main(){
1010
c++;
1111
}
1212
printf("Number of students between 15 to 22: %d\n", c);
13-
}
13+
}

‎Array Questions/q3.c‎ renamed to ‎Array Questions/3_arrange_ascending.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ int main(){
2121
printf("%d\t", a[i]);
2222
}
2323
return 0;
24-
}
24+
}

‎Array Questions/q4.c‎ renamed to ‎Array Questions/4_transpose_matrix.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ int main(){
2222
}
2323
printf("\n");
2424
}
25-
}
25+
}

‎Array Questions/q5.c‎ renamed to ‎Array Questions/5_sum_of_matrix.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ int main(){
2323
printf("\n");
2424
}
2525
return 0;
26-
}
26+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// matrix multiplication
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
int mult_matrix(int, int, int, int);
6+
7+
int main(int argc, char *argv[]) {
8+
int row1, column1, row2, column2;
9+
printf("================================\n");
10+
printf("Enter number of rows and columns for the first matrix:\n");
11+
scanf("%d%d", &row1, &column1);
12+
printf("================================\n");
13+
printf("Enter number of rows and columns for the second matrix:\n");
14+
scanf("%d%d", &row2, &column2);
15+
printf("================================\n");
16+
// check to see if any of the rows and columns are negative
17+
if (((row1 * column1) < 1) && ((row2 * column2) < 1)) {
18+
printf("Enter non-negative value.\n");
19+
exit(EXIT_FAILURE);
20+
} else {
21+
if (column1 != row2) {
22+
// check to see if the number of column of first matrix is equal to the
23+
// number of rows of second matrix;
24+
printf("Number of column of first matrix must be equal the row of second "
25+
"matrix.\n");
26+
exit(EXIT_FAILURE);
27+
28+
} else {
29+
// if all the conditions are true, then call the mult_matrix function
30+
mult_matrix(row1, column1, row2, column2);
31+
}
32+
}
33+
34+
return 0;
35+
}
36+
37+
int mult_matrix(int row1, int column1, int row2, int column2) {
38+
int arr1[row1][column1], arr2[row2][column2];
39+
// take input for first matrix
40+
for (int i = 0; i < row1; i++) {
41+
for (int j = 0; j < column1; j++) {
42+
printf("For first matrix:\n");
43+
printf("Enter element number [%d][%d]:\n", i + 1, j + 1);
44+
scanf("%d", &arr1[i][j]);
45+
}
46+
}
47+
48+
printf("================================\n");
49+
// take input for second matrix
50+
for (int i = 0; i < row2; i++) {
51+
for (int j = 0; j < column2; j++) {
52+
printf("For second matrix:\n");
53+
printf("Enter element number [%d][%d]:\n", i + 1, j + 1);
54+
scanf("%d", &arr2[i][j]);
55+
}
56+
}
57+
printf("================================\n");
58+
59+
// multiplying the two matrixes
60+
int result[row1][column2];
61+
for (int i = 0; i < row1; i++) {
62+
for (int j = 0; j < column2; j++) {
63+
result[i][j] = 0;
64+
for (int k = 0; k < column1; k++) {
65+
// either column1 or row2 can be used
66+
result[i][j] += arr1[i][k] * arr2[k][j];
67+
}
68+
}
69+
}
70+
71+
// muliplied matrix
72+
printf("Result of the product of those two matrixes\n");
73+
for (int i = 0; i < row1; i++) {
74+
for (int j = 0; j < column2; j++) {
75+
printf("%d\t", result[i][j]);
76+
}
77+
printf("\n");
78+
}
79+
80+
return 0;
81+
}

‎Basic Questions/q1.c‎ renamed to ‎Basic Questions/1_positive_negative.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ int main(){
88
if(a == 0)
99
printf("Zero\n");
1010
else if (a > 0)
11-
printf("Positive");
11+
printf("Positive\n");
1212
else
13-
printf("Negative");
13+
printf("Negative\n");
1414
return 0;
15-
}
15+
}

‎Basic Questions/q2.c‎ renamed to ‎Basic Questions/2_simple_interest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ int main(){
1818

1919
return 0;
2020

21-
}
21+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /