Don't understand how this program came out with this output

So here is the program I am working with

#include <iostream>
using namespace std;
void test(int, int = 1, int = 1);
void test(int, int *, int &);
void test(int *, int[], int);
const int SIZE = 4;
int main()
{
int first = 1, second = 2, third = 3;
int array[SIZE] = { 3, 6 };
test(third, second);
cout << first << "," << second << "," << third << "," << endl;
test(&second, array, SIZE);
for (int i = 0; i < SIZE; i++)
cout << array[i] << ",";
cout << endl;
test(array[1], &array[2], array[3]);
for (int i = 0; i < SIZE; i++)
cout << array[i] << ",";
cout << endl;

system("pause");
return 0;
}

void test(int first, int second, int third)
{
first += 10;
second += 20;
third += 30;
cout << first << "," << second << "," << third << "," << endl;
}

void test(int * p, int num[], int SIZE)
{
*p = SIZE;
for (int i = 0; i < SIZE; i++)
*(num + i) += *p;
}

void test(int first, int *second, int & third)
{
first += 5;
*second += 3;
third += 4;
}

the output I am getting is;

13,22,31
1,2,3
7,10,4,4
7, 10, 7, 8

I don't understand how the last void test function got the output of 7,10,7,8

I'm looking at the previous functions and calls it just doesn't add up to the numbers in the void test so I am confused
What are you expecting the result to be?


1
2
test(array[1], &array[2], array[3]);
//sending in (10,4,4), either by value or by reference so that the original value in main may or may not get updated 


1
2
3
4
5
6
void test(int first, int *second, int & third)
{
first += 5;
*second += 3;
third += 4;
}
Topic archived. No new replies allowed.