Tons of || in an if
I don't understand why this does not work. I know that there are better ways to do this program but I'm just concerned about why it didnt work:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
long double pi = 0.0, num = 4.0, denom = 1.0;
long acc = 10000;
int n;
cout << setiosflags( ios::fixed | ios::showpoint )
<< "count set at: " << acc << "\nterm\t\t pi\n";
for ( long loop = 1; loop <= acc; ++loop ) {
if ( loop % 2 != 0 )
pi += num / denom;
else
pi -= num / denom;
if ( (loop == 10000) || (loop == 10001) || (loop == 10002) || (loop == 10003)
|| (loop == 10004) || (loop == 10005) || (loop == 10006) || (loop == 10007) || (loop == 10008)
|| (loop == 10009) || (loop == 10010) || (loop == 10011) || (loop == 10012) || (loop == 10013)
|| (loop == 10014) || (loop == 10015) || (loop == 10016) || (loop == 10017) || (loop == 10018)
|| (loop == 10019) || (loop == 10020) || (loop == 10021) || (loop == 10022) || (loop == 10023)
|| (loop == 10024) || (loop == 10025) || (loop == 10026) || (loop == 10027) || (loop == 10028)
|| (loop == 10029) || (loop == 10030) )
cout << loop << "\t\t" << setprecision( 8 ) << pi << '\n';
denom += 2.0;
}
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
It only prints out the very first loop.
for ( long loop = 1; loop <= acc; ++loop )
What values does loop stop at in this for loop?
expletive expletive expletive expletive expletive
Alright, I understand. Dangit.
Topic archived. No new replies allowed.