# Thread: Recursive function and apvector

1. ## Recursive function and apvector

I have the task of creating a program that lets the user input numbers into an apvector then let them enter a goal(final number), and have a recursive function tell whether or not the numbers in the apvector can add up to be exactly the goal number. Im not sure where to start but this is what i have done so far.

Code:
```bool IsPossible(const apvector <int> &A, int goal)
{

// I think i need code to add the elements of an apvector but
//I dont know how to do something like that

if( *****  == goal)
return true;
else

}```

2. try this example for adding elements of apvector:

Code:
```bool IsPossible(const apvector <int> &A, int goal)
{

A.resize(20);  // resize comes with apvector, the 20 can replaced by how large you want the array to be

cout << "Enter number 1: ";
cin >> A[0];
cout << endl;

cout << "Enter number 2: ";
cin >> A[1];
cout << endl;

// To add elements of an array;
A[0] + A[1] = A[2];

// You can also do something like this
int Num;
A[0] + A[1] = Num;

/*
if( *****  == goal)
return true;
else
*/

}```

3. You can't do this..

A[0] + A[1] = A[2];
A[0] + A[1] = Num;

You cannot assign to a temporary variable. The result of A[0] + A[1] is a tempoarry. Perhaps you wanted the reverse?