Function and Arrays

Sep 9, 2014 at 6:59pm
so basically im collecting the user's input and depending on their choice, the output will be averaged or simply displayed.
I have tried running my code and its successful. can someone help me out please?
here is what i have so far.
if there is anything i should change please let me know, thank you.
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  /* 
 * File:   main.cpp
 * Author: gears
 *
 * Created on September 9, 2014, 12:28 AM
 */

#include <cstdlib>
#include <iostream>

using namespace std;

double getScores(double testScores[SIZE]);
void showMenu();
char getChoice(char choice);
double disoplayResult(char choice, double testScores[SIZE]);

const int SIZE =5;


/*
 * 
 */
int main(int argc, char** argv) {
    
    double testScores[SIZE];
    char choice;
    
    getScores (testScores);
    return 0;
}

double getScores(double testScores[SIZE])
{
    cout << "what are the 5 test scores? "<< endl;
    
    for ( int i; i < SIZE; i++)
    {
        cin >> testScores[i];
    }
    system ("cls");
}
void showMenu()
{
    system ("cls");
    
    cout << " A.) Calculate the average of the test scores. "<< endl;
    cout << " B.) Display all test scores. "<< endl;
    
}
char getChoice(char choice)
{
    char letter;
    system ("cls");
    
    cout << " Please enter a choice ";
    cin >> letter;
    return letter;
}
double disoplayResult(char choice, double testScores[SIZE])
{
    system ("cls");
    
    float sum = 0;
    float average =0;
    
    if (toupper(choice)== 'a')
    {
        for ( int i=0; i <=SIZE; i++)
    {
        sum += testScores[i];
    }
    average=sum/(SIZE+1);
    cout << "the average is "<< average << endl;
    }
    else if (toupper(choice)== 'b')
    {
        cout << "These are your TestScores "<< endl;
        for ( int i = 0; i < SIZE; i++)
        {
            cout << testScores[i]<< endl;
        }
        
    }
    
    
}
Sep 9, 2014 at 7:33pm
can someone help me out please?

With what?

main calls getScores, but none of your other functions are called.
Sep 9, 2014 at 9:31pm
oh...lol no wonder it doesnt work haha
Topic archived. No new replies allowed.