#include <stdio.h> #include <time.h> int sum(int* a, int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += a[i]; } return sum; } int main() { int a[10000]; for (int i = 0; i < 10000; i++) { a[i] = i; } clock_t start = clock(); int result = sum(a, 10000); clock_t end = clock(); double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; double cpe = cpu_time_used / 10000; printf("Sum: %d\n", result); printf("Time used: %f seconds\n", cpu_time_used); printf("CPE: %f\n", cpe); return 0; }