just keep top two large number
#include #include #define SWAP(x,y) {int t; t = x; x = y; y = t;} int findMaxSum(int *numbers, int size) { int max1 = 0, max2 = 0; for(int i = 0; imax1){ max1 = numbers[i]; } if(max2<max1){ SWAP(max1, max2); } } return max1 + max2; } #ifndef RunTests int main() { int v[] = { 5, 9, 7, 11, 1, 2, 3, 4, 5, 20}; printf("%d", findMaxSum(v, 10)); } #endif