Move History

Fork Selected
  • Description

    One liner.

    Code
    #include <stdio.h>
    
    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
    #include <criterion/criterion.h>
    
    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
        );
    }
  • 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;
    • }