What are the syntax/logic errors in this code? I am confused between the two types.
[code]
int i;
double pi;
pi = 1.0;
for (i=2; i<n, i=i+1)
{
if (i%2 = 1)
pi = pi - (1.0 / ((2.0*i)+1));
else
pi = pi + (1.0 / ((2.0*i)+1));
}
pi = pi * 4.0;
[code]/*
also how can I make the output more accurate?
[code]
int i;
double pi;
pi = 1.0;
for (i=2; i<n, i=i+1)
{
if (i%2 = 1)
pi = pi - (1.0 / ((2.0*i)+1));
else
pi = pi + (1.0 / ((2.0*i)+1));
}
pi = pi * 4.0;
[code]/*
also how can I make the output more accurate?
Comment