Skip to content

Instantly share code, notes, and snippets.

@rohan-varma
Created September 9, 2016 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohan-varma/e85ba84b1287be8a7f6b58a5e98816c6 to your computer and use it in GitHub Desktop.
Save rohan-varma/e85ba84b1287be8a7f6b58a5e98816c6 to your computer and use it in GitHub Desktop.
int getProduct(int* arr, int len, int index) {
//return product of all ints except at that index
int prod = 1;
for(int i = 0 ; i < len; i++) {
if(i!=index) {
prod*=arr[i];
}
}
return prod;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment