Open
Description
For question no 16.c of arrays there is a minor issue in Method 3
int findEquilibriumIndex(int a[],int n){
int i = 0,j;
int sum = 0, sumLeft = 0;
for(i=0; i<n; i++){
sum += a[i];
}
for(j=0;j<n;j++){
sum = sum - a[j];
**sumLeft += a[j];** //Should have come after if condition
if(sum == sumLeft){
return j;
}
}
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels