Infinitely looping a certain piece of my program

Hi I am trying to write a program that requires a repeat to infinity. However I am not sure how to do this I am trying to use the Taylor series to find the sine of an angle and the series is:

sin(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7!...

This pattern the repeats forever I have tried using a while (true) statement but I cant seem to get that to work how can I get this to work

here is what i have so far


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# include <iostream>
#include <cmath>

using namespace std;

int factorial (int x)

{ if (x ==1)

return 1;

	return ( x * factorial(x-1));
}
int main ()
{
	double angle;
	int n = 0;
	int x = 1;

	cout << "Please enter the value of the angle in radians";

	cin >> angle;

	cout << "The sine of the angle is " << sin(angle) << endl;

	cout << "using the taylor series the sine of the angle is " << endl;

		while (true){ 

		angle - (pow (angle,3+2*n)/(factorial(3+2*n++))) << endl;}

		return 0;
	}
while (true){

when you use this syntax, you need to include a
break;

condition otherwise it will never stop....
Topic archived. No new replies allowed.