apprx pi calculation "expression must be a modifiable value"

error "expression must be a modifiable value" ...
Calculating pi for 10,000; 20,000; 30,000 .... 100,000;

Getting the "must be a modifiable value" on the if statement where it says:
"if (i == 10,000 || i==20,000 ... etc) the 'i' is what is receiving the error

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
35
36
 #include <iostream>


using namespace std;
int main ()
{
	int i, num = 100000;
	double pi = 0;
	cout << "Find the apprx value of pi:" << endl;

	for (i = 1; i <= num; i++) 
	{
		if (i % 2 == 0) 
		{
			pi = pi-(1.0 / (2.0 * i - 1));
		}
		else 
		{
			pi = pi + (1.0 / (2.0 * i - 1));
		}
		if (i == 10000 || i == 20000 || i == 30000 || i == 40000 || i == 50000 || i == 60000 || i == 70000 || i == 80000 || i == 90000 || i = 100000)
		{
			pi = pi * 4;
			cout << "For i=\n";
			cout << ", the approximate value of pi is: \n";
			pi = pi / 4;
		}
		
	}

	
	system("pause");

	return 0;
}
Look VERY closely at the last comparison on line 21.

BTW, you never actually output either i or your estimates of pi.
Last edited on
oof, I see, missing the second =
Thank you so much!
Topic archived. No new replies allowed.