There was a post about this before: http://www.daniweb.com/forums/thread88472.html

but no code in it, this is the code I have written and it calculates the sine of x, but not exactly what I was asked to do, I have set counter to 15, and there should be no counter, it should stop when fsum/sum2 < 1e-8. I think this should be done with a do while function, I have tried putting the whole thing inside one but it doesnt work that way, since it finishes the counter first and then goes to the while with the final result. Someone please help.

```
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
int main()
{
clrscr();
double x,sum,mult=0,count,sign=1,fsum,count2,mult2=3,sum2=2,fres=0;
cin>>x;
sum=x;
for (count=1;count<15;count=count+2) //first loop for x-x^3+x^5-x^7...
{
sign=-sign;
mult=x*sum;
sum=x*mult;
fsum=sum;
fsum=fsum*sign;//changes sign, 1st one + 2nd one - 3rd one + ....
for (count2=count2;count2<count;count2++)//second loop for 3! 5! 7!...
{
sum2=sum2*mult2;
mult2++;
}
cout<<fsum/sum2<<endl;//-x^3/3! +x^5/5! ...
fres=fres+(fsum/sum2); //final result here is sine of x, still gotta add x^1
}
cout<<x+fres<<endl;//its +x because at the and gotta add x^1, loop calculates starting
//from -x^3
getch();
return 0;
}
```