Need help with homework problems

Hi all,

I joined these forums (in part) because I am stumped with a recent "homework" problem given to me by someone helping me learn C++. I would say I am certainly a beginner.

I need to solve the following with 10e-12 accuracy,

sinx = (xe3/3!) + (xe5/5!) - (xe7/7!) + (xe9/9!) and so on

for the value of 73 degrees. I know how to convert inputted 73 degrees to radian, but I don't know how to write out the loop for the series in order to (1) increment the factorial values (2) increment the exponent values (3) alternate signs between terms.

Help would be greatly appreciated; I intend on handing him a copy of my finished work tomorrow afternoon when I stop by his business.



Thank you in advance!!
closed account (D80DSL3A)
nvm
Last edited on
Hi
Try this for the factorial


1
2
3
4
5
6
7
int factorial(int number)
{
	if (number > 1)
		return number*factorial(number - 1);
	else
		return 1;
}


and just use
 
factorial(value) // anywhere u need in your code it will return the factorial of that number right away 


gl with the homework :)
Last edited on
Topic archived. No new replies allowed.