Created
October 24, 2015 16:18
-
-
Save AndrewRademacher/e70f78d038d64ae626b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
using namespace std; | |
int sumArray(int inputArray[], int arrayCount) { | |
if (arrayCount == 1) { | |
return inputArray[0]; | |
} | |
else { | |
inputArray[0] = inputArray[0] + inputArray[arrayCount - 1]; | |
int newCount = (arrayCount - 1); | |
return sumArray(inputArray, newCount); | |
} | |
} | |
int main(int argc, char **argv) { | |
int ary[3]; | |
ary[0] = 4; | |
ary[1] = 5; | |
ary[2] = 7; | |
int sum = sumArray(ary, 3); | |
printf("%i\n", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment