Add subtract loop c++

// i know this may seem like way to beginer but i need to know how to make a for loop with a mod to either add when positive or subtract when negative.

//heres what i have so far

using namespace std;

int main(){
unsigned long int pi, itteration, iResult=0;

for(int n = 0; n < 10; n++){
cout << " " << pow(static_cast<double>(-1), n) * (2*n + 1);
if(n % 2 == 0) iResult = n - iResult;
else iResult = n + iResult;
cout <<"\n\n";

If I'm getting it,
if(n % 2 == 0) should be if(n<0)

Hope it helps,
Use proper indentation and code tags please, makes the post a lot easier to read.
Topic archived. No new replies allowed.