Hi folks, I have a problem with my code which I can't work out:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
double Mi = 200*pow(10,30);
cout << "\nEnter accreted mass increment in solar masses \n";
cin >> dm;
cout << "\nEnter total mass accreted onto black hole in solar masses \n";
cin >> total_accreted;
double nsteps = total_accreted / dm;
for (int i=0; i<nsteps; i++)
{
Macc = dm*2*pow(10,30);
//Lots of equations here...
Mi = Mi + Macc;
}
Basically the loop works, but gives the wrong results.
I need, at the end of the loop, to sort of "redefine" Mi as "Mi + Macc". I then need it to repeat the loop, and at the end add another Macc so that Mi becomes "Mi + Macc + Macc", etc.
Hope that makes sense. I assumed that was what the last line of my above code would do, but it doesn't and I have no idea how!
Any help appreciated, oh and please try to keep it "n00b-friendly" ;)
keskiverto - so the statement in line 17 should actually work? All other equations inside the loop fundamentally depend on Mi, but that shouldn't change the value of Mi. Starting think something else may be the problem.
topnik1 - if I can't work it out soon then I'll quote the whole code. It's just full of confusing equations so I thought it'd be simpler for people to work out this way.