#include <math.h>
using namespace std;
int main(int argc, char* argv[], char* envp[])
{
long lRoot = 1;
// sum of terms
float fSum = 0.0f;
// to test whether value has changed since last iteration
float fChecksum = 0.0f;
//mainloop
do
{
fChecksum=fSum;
fSum=fSum + (1 / pow (lRoot, 3));
lRoot++;
}
while (fSum != fChecksum)
cout << fSum << endl;
return 0;
}
Before someone flames me that the equality test is flawed because of rounding errors. I already know.I also realise that this is strictly-speaking, c++ and not c. Only the output to stdout needs changing though, simple to do, I think. And I can't be bothered.