Need help

hi guys im very new in C++ ..my problem is how to create a function that calculate its percentage to every rows of the table..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main()
{
    int candidate [5][6]={
    {1,192,48,206,37},
    {2,147,90,312,21},
    {3,156,12,121,38},
    {4,114,21,406,39},
    {5,267,13,382,29},

};
    cout << "\n     Precinct\tA\tB\tC\tD" << endl;
    cout << "\n\t" << candidate [0][0] << "\t" << candidate [0][1] <<"\t" << candidate [0][2] << "\t" << candidate [0][3] << "\t" << candidate [0][4] << "\t" <<endl;
    cout << "\t" << candidate [1][0] << "\t" << candidate [1][1] << "\t" << candidate [1][2] << "\t" << candidate [1][3] << "\t" << candidate [1][4] << "\t" <<endl;
    cout << "\t" << candidate [2][0] << "\t" << candidate [2][1] << "\t" << candidate [2][2] << "\t" << candidate [2][3] << "\t" << candidate [2][4] << "\t" <<endl;
    cout << "\t" << candidate [3][0] << "\t" << candidate [3][1] << "\t" << candidate [3][2] << "\t" << candidate [3][3] << "\t" << candidate [3][4] << "\t" <<endl;
    cout << "\t" << candidate [4][0] << "\t" << candidate [4][1] << "\t" << candidate [4][2] << "\t" << candidate [4][3] << "\t" << candidate [5][4] << "\t" <<endl;

    return 0;

}
Here is a hint.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

void printArray(int candidate[][6]);
using namespace std;

int main()
{
    int candidate [5][6]={
    {1,192,48,206,37},
    {2,147,90,312,21},
    {3,156,12,121,38},
    {4,114,21,406,39},
    {5,267,13,382,29},
    };
    printArray (candidate);
    return 0;
}

void printArray(int candidate[][6])
{
    cout << candidate[0][0] << endl;
}
Topic archived. No new replies allowed.