about function

Hello,
I have wrote such code
Question is so when I declare
const int NUM = 5; // it's ok
but when
const int NUM = 9; // I have got 1.565458e+455
what is the mater?
and how solve it? :)
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
42
43
44
45
46
47
48
49
  #include <iostream>

using namespace std;
const int NUM = 9;
void score(int []);
void show(int []);
double average(const int[], int);
int main()
{
    int scoreArr[NUM];

    score(scoreArr);
    cout << endl;
    show(scoreArr);
    cout << endl;
    cout << "the average is " << average(scoreArr, NUM);
    return 0;
}
void score(int sc[])
{
    cout << "Please enter 10 games scores: ";
    for(int i=0; i<NUM; i++)
    {
        cout << i+1 << " game score is: ";
        cin >> sc[i];
    }

}
void show(int sh[])
{
    cout << "The all score of games are: ";
    for(int i=0; i<NUM; i++)
    {
        cout << sh[i] << " ";
    }
}
double average(const int av[], int con)
{
    double num;
    for(int i=0; i<NUM; i++)
    {
        num += av[i];

    }
    double averr = num/con;
    return averr;
}





line 39 double num;
Initialise your variables.
Topic archived. No new replies allowed.