what is wrong with MininumEntry???Code:#include <iostream> using namespace std; void printarray (int arg[], int length) //printarray will print the numbers in the array { for (int n=0; n<length; n++) cout << arg[n] << " "; cout << "\n"; } int MinimumEntry (int a[], int n) { if (n==1) return a[0]; int result = MinimumEntry(a+1, n-1); // note the a+1 and corrected name if (a[0] < result) return a[0]; else return result; } int main () { int firstarray[] = {3,2,3,-4,5,6}; int secondarray[]={ 3,2,3,4,5,6}; int thirdarray[]={3,2,3,-4,5,6}; cout<<"First Array is: "; cout<<endl; printarray (firstarray,6); cout<<"Second Array is:"; cout<<endl; printarray(secondarray,6); cout<<"Third Array is:"; cout<<endl; printarray(thirdarray,6); cout<<endl; cout<<"sum of First Array ="; cout<<endl; MininumEntry(firstarray,6); return 0; }
thanks




Reply With Quote