a simple vector as an argument of a function

Dear All,

I wrote two simple functions one of which works (sum) and the other (deduct) gives same values for all vector elements. Where did I go wrong???

Thank you

Code:

vector <double> deduct (const vector<double>& v, double k)

{

vector<double> d(v.size());

for(int i=0; i < v.size();++i)

d[i]=v[i]-k;

return d;

}

double sum (const vector<double>& v)

{

double c=0.000000000;

for(int i=0; i < v.size();++i)

c +=v[i];

return c;

}

#include <vector>

main()

{

vector <double> vect(8);

double fidy []={112.999,112.994,112.994,-0.005,-0.007,-13.004, -113.003,-113.005};

vector<double> yfid(fidy,fidy+imarknum);

double k=sum (vect);

v=deduct (vect, k);

}

Corrections are being made

Code:

`using namespace std;`

.

.

.

main()

.

.

imarknum=8;

vector <double> v(8);

but result is still the same.