loop question

What are the values of i and n after this loop executes?
int n = 0;
for(int i = 1; i <= 8; i++) {
n = n + (i % 2);
}


This isn't a hard question. You won't learn anything if we just give you the answer. Get out a pencil and paper, and write down the values of i and n each time through the loop.
Or you could just print it out.. A pretty obvious way to tell. Either way you can figure it out in your head.
Topic archived. No new replies allowed.