
Write a function that fills a separate output buffer with the running totals of an integer array, one total per element.
int a[] = {1, 2, 3}; long out[3]; prefix_sum(a, 3, out);1 3 6int a[] = {5, -2, 7, -10}; long out[4]; prefix_sum(a, 4, out);5 3 10 0int a[] = {2000000000, 2000000000, 2000000000}; long out[3]; prefix_sum(a, 3, out);2000000000 4000000000 6000000000int a[] = {10, 20, 30, 40}; long out[4] = {-7, -7, -7, -7}; prefix_sum(a, 2, out);10 30 -7 -7int a[] = {7, 8, 9}; long out[3] = {-1, -1, -1}; prefix_sum(a, 0, out);-1 -1 -1prefix_sum.c<stddef.h>defines size_t
Run the tests to grade your code
Write a function that fills a separate output buffer with the running totals of an integer array, one total per element.
int a[] = {1, 2, 3}; long out[3]; prefix_sum(a, 3, out);1 3 6int a[] = {5, -2, 7, -10}; long out[4]; prefix_sum(a, 4, out);5 3 10 0int a[] = {2000000000, 2000000000, 2000000000}; long out[3]; prefix_sum(a, 3, out);2000000000 4000000000 6000000000int a[] = {10, 20, 30, 40}; long out[4] = {-7, -7, -7, -7}; prefix_sum(a, 2, out);10 30 -7 -7int a[] = {7, 8, 9}; long out[3] = {-1, -1, -1}; prefix_sum(a, 0, out);-1 -1 -1prefix_sum.c<stddef.h>defines size_t
Run the tests to grade your code
Memory will appear here