## Void Functions with Arrays

### Codesnip:

```//Programmer: Nazmus
//Program:  Void Function Tutorial #2 - Arrays in Functions
//Website:  www.EasyProgramming.net

#include <iostream>
#include <string>

using namespace std;

void calc(int test1[], int test2[], float avg[]);
void total(float avg[], float & totalavg);

int main()
{
string name[3];
int test1[3];
int test2[3];
float avg[3];
float totalavg;
int i;

for(i=0;i<=2;i++){

cout << "Please enter student's name: ";
cin >> name[i];

cout << "Please enter first test score: ";
cin >> test1[i];

cout << "Please enter second test score: ";
cin >> test2[i];
}

calc(test1, test2, avg);
total(avg, totalavg);

cout << endl;

cout << "Name" << "          " << "Average" << endl;

for(i=0;i<=2;i++){
cout << name[i] << "          " << avg[i] << endl;
}

cout << endl << endl;

cout << "The overall average of the grades is: " << totalavg << '.' << endl << endl;

system("pause");
}

void calc(int test1[], int test2[], float avg[]){

int i;
for(i=0;i<=2;i++){
avg[i] = (test1[i] + test2[i]) / 2;
}

}

void total(float avg[], float & totalavg)
{
int i;
float total;
total = 0;

for(i=0;i<=2;i++)
{
total=total + avg[i];
}

totalavg = (total/3);
}```