#include <stdio.h>
extern unsigned long long sum(unsigned int *array, size_t n);
int
main(void)
{
unsigned int array[] = { 1, 1, 1, 3 };
unsigned long long r = sum(array, sizeof(array) / sizeof(*array));
printf("Result is: %llu (%s)\n", r, r == 6 ? "correct" : "incorrect");
return 0;
}
Complete the code for the line that calls the sum function. Write the sum function.
#include <stdio.h> extern unsigned long long sum(unsigned int *array, size_t n); int main(void) { unsigned int array[] = {1, 1, 1, 3}; unsigned long long r = sum(array, sizeof(array) / sizeof(*array)); printf("Result is: %llu (%s)\n", r, r == 6 ? "correct" : "incorrect"); return 0; } unsigned long long sum(unsigned int *array, size_t n) { unsigned long long total = 0; size_t i; for (i = 0; i < n; ++i) { total += array[i]; } return total; }
Get Answers For Free
Most questions answered within 1 hours.