CJCoding With Joseph
15free / daySign inCreate account

Multiplication Grid Through an int Double Pointer

Build a two-dimensional grid on the heap using a double pointer (int **): an array of rows row pointers, each owning its own block of cols ints.

Read two integers from input on the first line: rows and cols. Fill the grid with a multiplication table — the value at row r, column c (both 0-based) is (r + 1) * (c + 1) — then print it, one row per line, with the values on a row separated by a single space and no trailing space.

For the input:

3 4

the output is exactly what is shown in Expected Output.

Each line ends with a newline. Print nothing else — no headings, no "Freed" message.

Free the memory you allocate before the program ends — this question checks for memory leaks: every row block, and the array of row pointers.

Expected Output:

1 2 3 4
2 4 6 8
3 6 9 12

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
3 4\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.