why is not reading

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#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;
}

why is not reading mininumentry???
thanks
MininumEntry(firstarray,6);

The function MinimumEntry has a data type - int. It has to be called in an expression, not a stand-alone statement like in line 38. Only void functions can be called in a stand-alone statement.
Also, on line 38 it is spelled wrong which will stop the program. instead on line 38 use:

int variable = MinimumEntry(firstarray,6);

and you will have the minimum entry stored as variable. I'm wondering how that relates to the sum of the array.
Topic archived. No new replies allowed.