-
Description One liner.
Code int prnt_mltply(int m, int n) { for (int i = 0; i < m; i++) for (int j = 1; j <= n; j++) printf("%d * %d = %d\n", i + 1, j, (i+1) * j); return m * n; }
Test Cases int prnt_mltply(int m, int n); void tester(int m, int n, int expected); Test(prnt_mltply, Sample_Test) { tester(5, 12, 60); } void tester(int m, int n, int expected) { int submitted = prnt_mltply(m, n); cr_assert_eq( submitted, expected, "< Incorrect Result >\n \nm = %d\nn = %d\n \nSubmitted: %d\nExpected: %d", m, n, submitted, expected ); }
Output:
-
Code - #include <stdio.h>
- int prnt_mltply(int m, int n) {
int i = 1;while(i <= m) {int j = 1;while(j <= n) {printf("%d * %d = %d", i, j, i * j);j++;}i++;printf("\n");}- for (int i = 0; i < m; i++) for (int j = 1; j <= n; j++) printf("%d * %d = %d
- ", i + 1, j, (i+1) * j);
- return m * n;
- }
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}