CJCoding With Joseph
15free / daySign inCreate account

calloc Proves the Bytes Are Zero

Read an integer n. Use calloc to allocate n ints, then print two lines:

- "Before:" followed by every element, each preceded by a single space
- then store i * i in element i, and print "After:" followed by every element the same way

For the input:

4

the output is exactly what is shown in Expected Output.

Format: the label, then one space before each number, and no trailing text.

Free the memory you allocate before the program ends — this question checks for memory leaks.

Expected Output:

Before: 0 0 0 0
After: 0 1 4 9

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

Hints4 available
Topics:
Pointers
📥 Auto-Input:
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.